473,789 Members | 3,013 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(objec t sender, System.EventArg s e)
{
Stream stream =
Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream("W ebStaging.Img.g if");
// read the file from assembly
Image img = Image.FromStrea m(stream);
img = new Bitmap(img, 25, 25); // resize to 25x25
string contentType = "image/png";
MemoryStream memStream = new MemoryStream();
img.Save(memStr eam, ImageFormat.Png );
byte[] rawBytes = memStream.ToArr ay();
Response.Conten tType = contentType;
Response.Binary Write(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 1281

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

Similar topics

6
16646
by: AMcD | last post by:
Hi! Here's a piece of code: <?php Header('Content-type: image/png');
3
18303
by: Scott Hatton | last post by:
I have a table like this
1
1553
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 to be tranparent for the entire UserControl. I've set the UserControl's backstyle 0-transparent, but I got transparent regions displayd in gray! There is a solution?
1
3431
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 the pictureBox I does not seem to work. I have put this pictureBox on top of another one, but its background is gray and it blocks the image. What am I doing wrong? Thanks
2
33532
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: --------------------------------------------------- this.BackColor = Color.Wheat; this.gameBackgroundBMP = new Bitmap(GetType(),"MyForm.backGround.bmp");
2
3150
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
2719
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 that is transparent"), to be semi transparent instead. So, I've wrapped the image in a div-tag with the style "opacity: .70" instead. This gives me pretty much the semi transparency that I'm looking for, except that this makes the entire image...
9
5874
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 overkill, but you can see what I mean. The watermark image (a png image) is included separately below the photo. I tried using a class from phpclasses.org <http://www.phpclasses.org/browse/package/1580.html...
3
1940
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 OnPaint an OnBackgroundPaint to draw stuff on the form, and when I set Opaque, what I draw is transparent as well. And I would like it not to be. I have also tried
0
9665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.