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. Show Image

Show Image

Scheduled Pinned Locked Moved ASP.NET
graphicshelpquestion
2 Posts 2 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.
  • A Offline
    A Offline
    AnhTin
    wrote on last edited by
    #1

    Hi all i have some code above. I have Some problem when i save this image is type Gif/ JPG so this image show but when i save is PNG is not yet And when i check C:\\demo.Png is Exist and open is ok but on web is not ok. ???? byte[] byImg = objimg.getBytes(); using (MemoryStream objStream = new MemoryStream(byImg)) { System.Drawing.Image img = System.Drawing.Image.FromStream(objStream); Bitmap bp = (Bitmap)img; //Check this image can show bp.Save("C:\\demo.Png", System.Drawing.Imaging.ImageFormat.Png); // Show image bp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png); }

    T 1 Reply Last reply
    0
    • A AnhTin

      Hi all i have some code above. I have Some problem when i save this image is type Gif/ JPG so this image show but when i save is PNG is not yet And when i check C:\\demo.Png is Exist and open is ok but on web is not ok. ???? byte[] byImg = objimg.getBytes(); using (MemoryStream objStream = new MemoryStream(byImg)) { System.Drawing.Image img = System.Drawing.Image.FromStream(objStream); Bitmap bp = (Bitmap)img; //Check this image can show bp.Save("C:\\demo.Png", System.Drawing.Imaging.ImageFormat.Png); // Show image bp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png); }

      T Offline
      T Offline
      The Tigerman
      wrote on last edited by
      #2

      Problem is the format of PNG is not compatible with the Response.OutputStream method directly, you need to store the image in a memorystream at then send that to the browser... System.IO.MemoryStream memStream; byte[] bytBuffer; Response.Clear(); Response.ContentType = "image/png"; memStream = new System.IO.MemoryStream(); bp.Save(memStream, System.Drawing.Imaging.ImageFormat.Png); bytBuffer = memStream.ToArray(); Response.OutputStream.Write(bytBuffer, 0, bytBuffer.Length); Response.End(); My C++ skills not good, this is a translation of the VB.NET code that I use.. :-D

      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