Using MakeTransparent one can supposedly turn a color used in a Bitmap to
transparent. But, it looks to me like all it does it set these pixels to the
color BackColor of the Control it's attached to. Thus, when I set White to
the transparent color of a Bitmap stored in the Image of a PictureBox and
placed the PictureBox on a Form which has a BackColor of black, it turned
the white pixels of the bitmap image to black, but these black pixels still
cover anything behind them! At least it seems to cover other PictureBox...
Am I missing something here? 7 3589
Hi,
I don't know how to fix this problem, but whenever I need transparency
these days I just use .gifs. Besides, it will save you a bit of space
and CPU usage for loading the graphics. I've always used them to keep
things simple.
James
Peter Oliphant wrote: Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent.
Try to use PNG. WinForms supports it and it's truly transparent. In
fact, it supports semi-trasparency (with the alpha channel), which lets
you use really nice looking icons. Also a PNG file is a fraction of a
BMP in size.
Tom
Thanx to both James and Tomas for your replies!!! : )
[==Peter==]
"Tamas Demjen" <td*****@yahoo. com> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl... Peter Oliphant wrote: Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent.
Try to use PNG. WinForms supports it and it's truly transparent. In fact, it supports semi-trasparency (with the alpha channel), which lets you use really nice looking icons. Also a PNG file is a fraction of a BMP in size.
Tom
BTW, I tried using JPG, GIF, and PNG files, and all of them still just
change the color of transparent pixels to the background color of the
control which is it's parent, and do not make them transparent. That is,
they still cover up anything behind them, but appear transparent only if the
background is a solid color and the images are not placed over anything
else, including other such 'sprites' which are suppose to have transparent
parts (which it covers with, for example, black pixels instead of seeing
through them).
This means of course it wil not be transparent at all if one uses a picture
for the background instead of a solid color!
Not that big a deal, but it would be nice to get true transparency. Keep in
mind no matter what the original form (i.e. file type) the image comes from
they all end up as internal Bitmap's in the Image property of a PictureBox,
so transparency must be handled at the Bitmap level (not the file level).
Any clues as to how to get TRUE transparency? : )
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:Of******** ******@TK2MSFTN GP14.phx.gbl... Thanx to both James and Tomas for your replies!!! : )
[==Peter==]
"Tamas Demjen" <td*****@yahoo. com> wrote in message news:u8******** ******@TK2MSFTN GP15.phx.gbl... Peter Oliphant wrote: Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent.
Try to use PNG. WinForms supports it and it's truly transparent. In fact, it supports semi-trasparency (with the alpha channel), which lets you use really nice looking icons. Also a PNG file is a fraction of a BMP in size.
Tom
Peter Oliphant wrote: BTW, I tried using JPG, GIF, and PNG files, and all of them still just change the color of transparent pixels to the background color of the control which is it's parent, and do not make them transparent.
Which component are you using it with? Have you set the control's style
to opaque in the constructor?
SetStyle(Contro lStyles::Opaque , true);
// control is drawn opaque and the background is not painted
Also try
SetStyle(Contro lStyles::UserPa int, true);
// the control paints itself rather than the operating system doing so
SetStyle(Contro lStyles::AllPai ntingInWmPaint, true);
// ignores the WM_ERASEBKGND
An example of what you're doing would be nice. When I place a PNG with
an alpha channel on my toolbar, it's not only transparent but fully
translucent, meaning the drop shadow has the color of the background.
The capability is there, it's just that most controls paint themselves,
and they're not designed to be fully transparent.
Tom
Peter Oliphant wrote: BTW, I tried using JPG, GIF, and PNG files, and all of them still just change the color of transparent pixels to the background color of the control which is it's parent, and do not make them transparent.
If it's a PictureBox, may I recommend that you set BackColor to
Transparent? If using the IDE, click on the drop-down arrow, go to the
Web tab, and the first color there is Transparent. To do the same
programmaticall y:
pictureBox1->BackColor = System::Drawing ::Color::Transp arent;
Tom
Thanks, Tomas, for responding! : )
Problem is, a line like:
pictureBox1->BackColor = System::Drawing ::Color::Transp arent;
just changes the BackColor to the specific color that
System::Drawing ::Color::Transp arent happens to be. That is, if this color is
Black, then it just changes the BackColor of the picture box to black, and
doesn't make it transparent.
What I've been doing is the following:
m_Bitmap->MakeTransparen t( trans_color ) ;
Where m_Bitmap is the Bitmap that is pointed to by Image of the PictureBox.
This method is described in the on-line MSDN as:
"Makes the default transparent color transparent for this Bitmap."
But it doesn't. It just displays all of the pixels of color 'trans_color' as
its container's BackColor. Transparency to me means you should be able to
see through the pixel, not just make it a color that will cause it to blend
in with a SOLID COLOR background!
It seems the documentation on this is wrong. I'd love to be wrong instead!
Any ideas? : )
[==P==]
"Tamas Demjen" <td*****@yahoo. com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl... Peter Oliphant wrote: BTW, I tried using JPG, GIF, and PNG files, and all of them still just change the color of transparent pixels to the background color of the control which is it's parent, and do not make them transparent.
If it's a PictureBox, may I recommend that you set BackColor to Transparent? If using the IDE, click on the drop-down arrow, go to the Web tab, and the first color there is Transparent. To do the same programmaticall y:
pictureBox1->BackColor = System::Drawing ::Color::Transp arent;
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Flo |
last post by:
Hi,
I'm trying to develop a COM interface in C# that would provide a bitmap
handle. In that DLL i do have a Bitmap object and i'm using the GetHbitmap
method to create a new similar bitmap and get its handle.
Everything seems to work well, except when there is some transparent zones
in the bitmap, the transparency color is changed in blue (default) right
after calling the GetHBitmap method.
|
by: Jax |
last post by:
So far i've not had much luck with this method.
Bitmap.MakeTransparent(someColor);
Makes the transparent colour either a non-transparent black (.bmp, jpg or .gif) or silver (.png) i've tried another solution with system.drawing making the selected color have a zero alpha setting (in the palette) but when the image is re-uploaded (saved as .gif) it shows no transparency.
Does anyone else have any experience in doing this in ASP.NET, if so what...
|
by: Carl Gilbert |
last post by:
Hi
I have to following code which sets up a new bitmap.
'set up a transparent 16x16 bitmap
Dim bm As New Bitmap(16, 16)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(System.Drawing.Color.Transparent)
'draw a rectangle on the transparent bitmap
|
by: Dennis |
last post by:
I have created a bitmap and set the transparency color to black;
mybitmap.MakeTransparent(Color.Black)
myicon = Icon.FromHandle(bm.GetHicon)
This creates the icon ok but the background color black is not transparent.
How do I create an Icon from this bitmap that has also the color black
transparent?
|
by: Dennis |
last post by:
I have a bitmap and make the color transparent;
mybitmap.MakeTransparent(Color.Black)
When I save it as a Icon, the black color is not transparent. However, if I
save it as a bitmap then display it using windows explorer, the black color
is in fact transparent. Could it be that the bitmap is not an alpha bitmap
that causes the icon to not have the black color transparent?
--
| |
by: Sharon |
last post by:
Hello Experts,
I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
But when I invoking the function myImage .MakeTransparent() (with or without
parameters), the myImage.PixelFormat changes to Format32bppArgb.
Why is that and how can I avoid it but still making the Bitmap transparent ?
|
by: Dennis |
last post by:
I have about 50 images in my application as "embedded resources". They are
Icon size (16x16 and 24x24 and 32x32). I can use either the bitmap version
or convert them to Icons. Either way seems to work ok (I make the color of
the upper left pixel in the bitmap's the transparent color). I noted that
the Icons take up 25k and the bitmaps only 1k). Which would be the
recommended way to go, i.e., icons or bitmaps in my imagelist? Any...
|
by: Dale |
last post by:
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how can I
set the transparency so that the background is transparent.
In my application, the Bitmap that I am working with has several transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.
Any help is greatly appreciated.
|
by: NickP |
last post by:
Hi there,
I have a usercontrol that inherits from Windows.Forms.Button.
In the OnCreateControl method I set the style of the control so that it supports transparent backcolor and set the background color to transparent.
.....
Protected Overrides Sub OnCreateControl()
|
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...
|
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,...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |