locked
byte[] to bitmap. When save to Response.OutputStream loose quality RRS feed

  • Question

  • User-482944373 posted
    Hi,

    I have to issues. Someone please help

    1.  I have an imge in byte[] format and when I stream it to the Response.OutputStream, it looks completey fine. The problem is eventhough I set the .ContentType="image/gif"..  the produced file ended with extension *.png! This is my code

    HttpContext.Current.Response.ContentType = "image/gif";
    HttpContext.Current.Response.OutputStream.Write(btImage1, 0, btImage1.Length);

    2.   To work around the issue in #1,  I tried to to convert the byte[] to Bitmap first and then send to OutputStream,

                 MemoryStream ms = new MemoryStream(btImage1);
                 Bitmap bmp = (Bitmap) System.Drawing.Bitmap.FromStream(ms);
                 bmp.Save(HttpContext.Current.Response.OutputStream,ImageFormat.Gif);


    but then I get a choppy image. What's going on?

    Thanks


    Thursday, April 6, 2006 6:58 AM

All replies

  • User-482944373 posted
    solved..

    in case anybody wants to know..  This is the issue. Before I get back the byte[] btImage1 from another method. that method should've saved the bitmap into a memorstream with ImageFormat.GIF before it gets converted to a byte[]. (something I didn't do. I convert it to byte[] directly)
     That's the crucial step.


    Thursday, April 6, 2006 5:33 PM