View Full Version : Python OGL, transparency in shapes
03-03-2003, 05:25 PM
When using images that have transparent sections, these sections show up as bright pink if the image is shown in as a wxShape. I tried to create a mask for this color, but then the shape no longer shows up at all. I also tried manipulating wxDC.SetLogicalFunction, wanting to choose the pixels in the background for places where the image is transparent. Is there a way to use transparency when using shapes, or do I have to place the images with something such as wxStaticBitmap? I lose a lot of useful OGL properties by resorting to that.
Not sure what you are tyring to achieve here.
If you have a bitmap (or other non alpha channel) file which has some sections bright pink to represent sections that should be transparent, you would probably need to manualy change the RGB file (bitmap) to a RGBA format. Any pixel with a color that matches the pink shoud have the alpha set to 1 all others should have a alpha of 0. One problem is that a bitmap is not in RGB format so you also need to change it to RGB at the same time.
When rendering, you just need to switch on the alpha blending.
I found a tutorial on NeHe(I think)
This may not be what you are talking about at all so just tell me to shut up. http://www.opengl.org/discussion_boards/ubb/smile.gif
03-04-2003, 05:38 AM
Oh dear, I really didn't explain that well at all. Well, let me copy somebody else's version of that same question...
> Hi List,
> I have created a simple program, in which I use wxBitmaps. In this
> program one bitmap may overlap with another, so I changed the code
> around so
> that bright pink (R = 255, G = 0, B = 255) is masked, and so ignored.
> But, as I found when two bitmaps did happen to overlap, the masked
> color is not transparent - all bright pink pixels are now white, so the
> pictures still hide each other!
> My question is, then, how would I go about making the bitmap's masked
> color transparent, so that the pictures don't hide each other?
It may depend on the LogicalFunction that is active in the DC, try
experimenting with that. I'll take a look at a small sample (including
images) if you still can't make it work.
So that's the same sort of thing that I'm dealing with, except I'm also trying to use wxShape with my bitmaps. The transparent section IS transparent, and just appears bright pink when shown. I played around with using wxDC but it doesn't seem directly compatible with shapes, more with drawing bitmaps. Does this all make a bit more sense now?
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.