Either research is failing me in this case, or I just don't want to accept the facts of how this works. Probably the second one. Is there a way in Win32 to use semi-transparent PNGs without using a second library? Or is the only way something like DirectX, or openGL?
Basically, I will have a semi-transparent PNG that will need painted once, and after that the BG will never change. (If that helps any) So do I need a second library? If so, what is a modern one that is compatible with XP and up?
Thanks, I'll see if I can make that work, but I'm not sure if I'll be able to due to the fact that my PNG images already have transparency, and it's not even across the entire image.
Okay, AlphaBlend only works with BMPs that don't have an alpha layer. ImageList will let me use one, but it displays the same. It would be nice if I could just use PNGs, but GDI+ doesn't allow me to use resource images.
Does anybody have a resource that shows how to read and place PNGs with proper transparency?
The SourceConstantAlpha member of BLENDFUNCTION specifies an alpha transparency value to be used on the entire source bitmap. The SourceConstantAlpha value is combined with any per-pixel alpha values. If SourceConstantAlpha is 0, it is assumed that the image is transparent. Set the SourceConstantAlpha value to 255 (which indicates that the image is opaque) when you only want to use per-pixel alpha values.
So it does allow per-pixel alpha. Did you set SourceConstAlpha to 255?
AlphaFormat should be AC_SRC_ALPHA (not zero), and the bitmap needs to have the RGB values pre-multiplied with the alpha channel, and the bitmap must be 32 bits per pixel.
Me neither. :) I'm thinking I'm just going to make myself understand GDI+ streaming so that I can stream from a resource. At least then I'll get my transparency correct.
Edit: GDI+ Can do what is needed. Still working on how to load a PNG from the resource files, but it works perfectly other wise. To future readers, if you're looking how to get a brush to have a transparent PNG, although it calls for an Image class, look into the Bitmap class to load it from the resoruce files.