O
Oleg Ogurok
Hi all,
I'm having this problem. I have a 50x50 GIF image with a transparent
background. I'm trying to resize it to 25x25 using GDI+ capabilities.
With Windows Forms' Image control, the image shows fine. However, when I try
to stream the image into a browser in a ASP.NET application, the background
that's supposed to be transparent looks grayish.
Here's my codebehind:
private void Page_Load(object sender, System.EventArgs e)
{
Stream stream =
Assembly.GetExecutingAssembly().GetManifestResourceStream("WebStaging.Img.gif");
// read the file from assembly
Image img = Image.FromStream(stream);
img = new Bitmap(img, 25, 25); // resize to 25x25
string contentType = "image/png";
MemoryStream memStream = new MemoryStream();
img.Save(memStream, ImageFormat.Png);
byte[] rawBytes = memStream.ToArray();
Response.ContentType = contentType;
Response.BinaryWrite(rawBytes);
Response.End();
}
I've tried streaming the file as GIF, the background becomes even darker.
Any suggestions are welcome.
Thanks,
-Oleg.
I'm having this problem. I have a 50x50 GIF image with a transparent
background. I'm trying to resize it to 25x25 using GDI+ capabilities.
With Windows Forms' Image control, the image shows fine. However, when I try
to stream the image into a browser in a ASP.NET application, the background
that's supposed to be transparent looks grayish.
Here's my codebehind:
private void Page_Load(object sender, System.EventArgs e)
{
Stream stream =
Assembly.GetExecutingAssembly().GetManifestResourceStream("WebStaging.Img.gif");
// read the file from assembly
Image img = Image.FromStream(stream);
img = new Bitmap(img, 25, 25); // resize to 25x25
string contentType = "image/png";
MemoryStream memStream = new MemoryStream();
img.Save(memStream, ImageFormat.Png);
byte[] rawBytes = memStream.ToArray();
Response.ContentType = contentType;
Response.BinaryWrite(rawBytes);
Response.End();
}
I've tried streaming the file as GIF, the background becomes even darker.
Any suggestions are welcome.
Thanks,
-Oleg.