Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. System.Drawing.Image to System.web.UI.Image

System.Drawing.Image to System.web.UI.Image

Scheduled Pinned Locked Moved ASP.NET
csharpgraphicsasp-netdatabasedesign
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VanithaVasu
    wrote on last edited by
    #1

    How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.

    VanithaVasu

    P V A 3 Replies Last reply
    0
    • V VanithaVasu

      How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.

      VanithaVasu

      P Offline
      P Offline
      Piyush Vardhan Singh
      wrote on last edited by
      #2

      u want draw image directly on aspx page From Database

      Piyush Vardhan Singh p_vardhan14@rediffmail.com

      1 Reply Last reply
      0
      • V VanithaVasu

        How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.

        VanithaVasu

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        VanithaVasu wrote:

        How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#.

        You have to save the Image to the Server (file path) and set the ImageUrl property of the Image control to the file path.

        VanithaVasu wrote:

        Is there any other way to display directly from the sql where i have stored the image with Image datatype.

        You can also use Binary datatype, which is common for all the binary files (doc, xls, whatever)

        [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

        V 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          VanithaVasu wrote:

          How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#.

          You have to save the Image to the Server (file path) and set the ImageUrl property of the Image control to the file path.

          VanithaVasu wrote:

          Is there any other way to display directly from the sql where i have stored the image with Image datatype.

          You can also use Binary datatype, which is common for all the binary files (doc, xls, whatever)

          [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

          V Offline
          V Offline
          VanithaVasu
          wrote on last edited by
          #4

          No, I have saved the image in the sql column as image datatype. And i have retrieved the image and converted to bytes[] as in the previous message. I am trying whether it works out from System.Drawing.Image to System.web.UI.Image. My Actual problem is to load the image directly to the treeview icons. Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.

          VanithaVasu

          modified on Monday, February 11, 2008 6:15 AM

          V 1 Reply Last reply
          0
          • V VanithaVasu

            No, I have saved the image in the sql column as image datatype. And i have retrieved the image and converted to bytes[] as in the previous message. I am trying whether it works out from System.Drawing.Image to System.web.UI.Image. My Actual problem is to load the image directly to the treeview icons. Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.

            VanithaVasu

            modified on Monday, February 11, 2008 6:15 AM

            V Offline
            V Offline
            Venkatesh Mookkan
            wrote on last edited by
            #5

            VanithaVasu wrote:

            Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.

            That is what I am telling you. There is not property as "Image" (which accepts bytes/System.Drawing.Image as value) in web world. So, you have to get the bytes and store it as a file (say mypicture.jpg), then use that image url and assign that to the ImageUrl property of your TreeView icons.

            [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

            1 Reply Last reply
            0
            • V VanithaVasu

              How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.

              VanithaVasu

              A Offline
              A Offline
              Aurelius1664
              wrote on last edited by
              #6

              You would have to create a seperate page or preferable an http handler for you image. You would set the image url on your tree view to this page with, for example, a query string parameter identifying the image in the database to be retrieved. e.g. ImageUrl = "MyImagePage.aspx?ImageId=XX"; Then inside your MyImagePage.aspx you would write some code along the lines of that shown below. Note: You must make sure no other content is sent down along with the bytes i.e. no html in the code infront if you use an aspx page (which is one reason why a handler would be better). // Get image bytes from database based on query string byte[] abImageData = (byte[])command.ExecuteScalar(); // Write image to stream Response.ContentType = "image/jpeg"; Response.Write(abImageData); Response.End();

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups