473,594 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

png image and transparency

When I populate a ToolStrip with ToolStripButton s with a .png-image on
it, will Windows understand the transparency of the .png file?
Oct 8 '07 #1
3 4209
On 8 okt, 17:51, Martijn Mulder <i@mwrote:
When I populate a ToolStrip with ToolStripButton s 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 TransparentColo r.
Usually, I choose Color.Magenta (r=255,g=0,b=25 5). 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 ToolStripButton s 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 "transparen t" 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 ToolStripButton s 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 "transparen t" 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
6567
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 that possible? -dg
0
1824
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 have private void createStdImage() { RenderedImage rImage = JAI.create("fileload", getName()); if (rImage instanceof PlanarImage)
3
3858
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 quality), and I don't know how to make the background. In every tool I open the image (html, flash, etc...) I see the original background color, and not the transparent color.
6
3984
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?!?!? Regards, Felix
4
2754
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 first then paint it larger? and how would i make the entire image transparent at 75% transparency (25% opaque) thanks!
2
1835
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, but always uses compression. The TIFF format preserves transparency and has an option for no compression, but that option doesn't seem to be supported by VB.NET. I'm intrigued by the image format called MemoryBMP; I'd like to test it out, but every...
1
1647
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 transparency property disappears when I render it making it look as if were a JPEG image. The code I use is: Assembly assem = this.GetType().Assembly; Stream streamTransPic =
4
10235
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 the transparency is working properly because if I save the created image to the local hard disk and then view it in a web page or an image editor, the transparency is correct. I can also view the transparency on-the-fly in a Windows.Forms...
1
2167
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: http://uplued.com/waffleimages/files/cb/cbbfce5e6067c8e770cf5e964a3dffd0cb65c0df.gif Unless you can think of a way for me to have it all in one graphic and have transparency? I'm not sure.
0
7946
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
8253
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
8374
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
8009
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
6661
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
5739
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...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
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
0
1216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.