This is a discussion on Rendering 32-bit images - alpha is ignored within the Windows Programming forums, part of the Platform Specific Boards category; Originally Posted by ulillillia Of course I know that, but some functions, like alpha blend, will not work when height ...
As I explained you don't need to specify a color table of 1 entry (not that useful), so you don't need RGBQUAD.
Looking again at your Massive Reply, it seems you call InitializeDrawing before loading the targa file. So you try to create a bitmap with no bitmap data and an uninitialized BITMAPINFOHEADER.
(Note that when you create a HBITMAP, the pixel data your pointer points to is copied, so you can't use your own pointer to change the data later on.)
Am I right?
Last edited by pronecracker; 04-18-2007 at 01:43 PM.
If I don't include RGBQuad, then AlphaBlend fails because the bitmapinfo thing has something uninitialized. If I do include it, then I just get compiler errors (cannot convert along with some others). You're saying I don't need it, but there's an uninitialized value if I don't include it. Please explain what I need to do.... You're only giving conflicting information.
Hey maybe you could just read my post and tell if I found the bug?
I'm not giving conflicting information. I explained what the RGBQUAD is for, and then I told you that you don't need it. In post #36 I gave you an example from my code, in which I implicitly set the RGBQUAD stuff to 0.
Last edited by pronecracker; 04-18-2007 at 02:02 PM.
Yes, it's working now and I calculated the resulting color displayed (after snagging a screenshot) and it is exactly what I'm expecting it to be. I ran my alpha transparency formula with the original on the background and the colors were off by fractions and rounding them gives identical values. I wonder what the premultiplication is used for and why it's needed.... Maybe for simplification of the formula (as, looking at my formula there, it's a little lengthy).
Yes, it was the placement of InitializeDrawing that messed things up. I moved it by using copy paste then commented out the original and it then worked. Yay! Now let's see if I can do the hills correctly which also has alpha. The bitmap font will be more complex since it gets cropped out with random amounts (for each character). I know how to get the character and location needed, cropping the image would be new. I'll try figuring that out on my own but if I'm unable to resolve it for some reason, then I'll ask about it again. Thanks for the assistance.
Yeah, finally, victory!! Pretty simple solution, actually.
I also noticed I misplaced the "initialize object positions" function. The two merely needed to be switched around. I've added the fog (and had a bug since I forgot to declare a char as unsigned then I had a copy paste mistake where I forgot to fix the array. The mountain's scaling is 1125 (exactly 10 miles distance) and the visibility is 1350 (exactly 12 miles). The fog now works exactly as expected. Yep, I've got the formula for fog as well, another derivative of the fundamental color-averaging formula. Next up, the hills (of which have a scaling of 900 (exactly 8 miles).
Great, it does not look hard at all to understand, your fog thing, if I'd only know what those words mean.
What are you confused about with the fog? The formula? What the fog does? I'm figuring out text displaying which uses AlphaBlend. I'm only having trouble getting wordwrap working right (infinite loops - oy!). The text stuff is a more complex usage of AlphaBlend. Everything is now working outside the text.
I only meant that I wouldn't know what BC, PDIST or VIS are.
BC - base color (the color without fog)
FG - fog color (the color of the fog at maximum intensity)
DIST - the object's distance (the more distance, the stronger the effect the fog has)
VIS - visibility (the distance at which fog has it's maximum effect).
MCOL - the resulting color, of which is displayed.
This screenshot shows the fog in my program. The visibility is 1350. The mountains have a scaling of 1125 making them 5/6 that of the fog color. The hills up closer have a scaling of 900 making them 2/3 that of the fog color. The houses have 3 making them almost unaffected by fog.
Edit: left out the MCOL variable
Last edited by ulillillia; 04-20-2007 at 12:28 PM. Reason: left out details
Ok thanks for that information, maybe I could use that some day.