473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Resizing a transparent image adds gray background

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().GetManifestResourc eStream("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.
Nov 19 '05 #1
0 1255

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: AMcD | last post by:
Hi! Here's a piece of code: <?php Header('Content-type: image/png');
3
by: Scott Hatton | last post by:
I have a table like this
1
by: jojo | last post by:
I' d like to develop an active x UserControl, using VB6, with transparent background. The user control will contains an image control. When load GIF image with transparent parts I want that parts ...
1
by: Richard Saville | last post by:
I am trying to make a transparent pictureBox. MSDN says to use this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); for the form and this.pictureBox1.BackColor = Color.Transparent; for...
2
by: Alex Gray | last post by:
Hi, I'm trying to make my PictureBox transparent to the BackgroundImage of the Form, not the BackColor of the form. Here's what i have: ---------------------------------------------------...
2
by: Mustafa Rabie | last post by:
hi all can someone tell me if there's a way to make the background of the control transparent and if i can make it opticy like the Form ? thanks mustafa
2
by: Trond Michelsen | last post by:
Hi. I have a transparent PNG-image that I would like to display on top of the rest of the web page. I've already got this part working. But, I'd like the background (as in "the part of the image...
9
by: Chuck Anderson | last post by:
Is it possible to overlay a transparent watermark on an image - dynamically? I'd like the result to look like this example: <http://www.cycletourist.com/temp/photo.php> That is a bit of...
3
by: Torleif Berger | last post by:
Is it possible to have a transparent Form? And by that I mean that the background should be transparent. I have tried to set the Opaque property, but that makes everything transparent. I use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.