473,320 Members | 1,817 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,320 software developers and data experts.

png image and transparency

When I populate a ToolStrip with ToolStripButtons with a .png-image on
it, will Windows understand the transparency of the .png file?
Oct 8 '07 #1
3 4186
On 8 okt, 17:51, Martijn Mulder <i@mwrote:
When I populate a ToolStrip with ToolStripButtons with a .png-image on
it, will Windows understand the transparency of the .png file?

Most Windows.Forms classes allow you to choose a color to consider
transparent. Usually this property is called TransparentColor.
Usually, I choose Color.Magenta (r=255,g=0,b=255). Just use this color
for all pixels that need to be transparent. The advantage is that it's
pretty easy to set up with basic image manipulation tools.

Cheers
Bram

Oct 8 '07 #2
Martijn Mulder wrote:
When I populate a ToolStrip with ToolStripButtons with a .png-image on
it, will Windows understand the transparency of the .png file?
Yes and no. Actually, I haven't tried this with a ToolStrip in
particular, but this did come up recently with other Control-based classes.

The transparency of the PNG is in fact preserved. However, the Control
background itself is still erased before the PNG with transparency is
drawn. This may apply to the ToolStripItem-derived classes too.

In this case, choosing "transparent" as the background color for the
item causes the background to be erased using the parent's color.
Assuming there's no overlap in your controls, this will have the net
effect of making the transparency in the image appear to work correctly.
But if there's overlap, you get that erased background on top of
whatever the underlying control is.

I don't actually know whether the ToolStripItem-derived classes have the
same behavior, but it seems possible that they would. Your best bet, of
course, is to try it. Then post back here with the answer. :)

Pete
Oct 8 '07 #3
Peter Duniho schreef:
Martijn Mulder wrote:
>When I populate a ToolStrip with ToolStripButtons with a .png-image on
it, will Windows understand the transparency of the .png file?

Yes and no. Actually, I haven't tried this with a ToolStrip in
particular, but this did come up recently with other Control-based classes.

The transparency of the PNG is in fact preserved. However, the Control
background itself is still erased before the PNG with transparency is
drawn. This may apply to the ToolStripItem-derived classes too.

In this case, choosing "transparent" as the background color for the
item causes the background to be erased using the parent's color.
Assuming there's no overlap in your controls, this will have the net
effect of making the transparency in the image appear to work correctly.
But if there's overlap, you get that erased background on top of
whatever the underlying control is.

I don't actually know whether the ToolStripItem-derived classes have the
same behavior, but it seems possible that they would. Your best bet, of
course, is to try it. Then post back here with the answer. :)

Pete

It works fine with my application. Only thing is that it seems 'to easy'
since I have gone through a lot of trouble defining a Region-object to
restrict the drawing to just the portion I want. And suddenly there is a
lot easier way with .png and transparency. C# is just to versatile
Oct 9 '07 #4

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

Similar topics

7
by: dan glenn | last post by:
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif, png) into another type? Especially, I know I can read a gif with GD2, but I really need to be able to save it as a png. Is...
0
by: Kenny | last post by:
I yant to put transparency in an image without transparency and without having to create a new image. This mean that I wan to read an image from the disk and add some alpha in it. for now, I...
3
by: Mr. x | last post by:
Hello, I would like that my image's background color will be transparent. What I have is only paintbrush. My image is *.jpg format (I have tried to save it as *.gif format, and I got less...
6
by: felix | last post by:
Hi, I have an Image that is drawn with Graphics.DrawImage(..). What I want to do is drawing it with a given transparency, e.g. at an alpha of only 180 instead of 255. How am I doing that?!?!?...
4
by: Brian Henry | last post by:
I have an icon I want to draw onto the screen, but I want to streatch it out to be about 256x256 and make it about 75% transparent how would I go about this? do i need to convert it to a bitmap...
2
by: TC | last post by:
Is there any way to save a bitmap in an uncompressed format which preserves transparency? The BMP format is uncompressed, but doesn't support transparency. The GIF format has an alpha channel,...
1
by: JimC | last post by:
I use reflection to get a GIF image that contains a transparency mask (the white background should be transparent) that is part of my C# project build. The problem is that the image's...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
1
by: FuzzyLogik | last post by:
I need the image to be in the CSS, because I plan to have multple stylesheets. The tricky part is I have 3 parts to the image, a top, the main bit, and right, Here is the image:...
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.