Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blt() to create a layer effect. Not working. Am I using the wrong logical function or something?

I have one window that is drawn to by various objects to create a layered effect (think of a heads up display where one object draws a compass, the other draws the grid lines, another the altimeter reading etc). So, each object has a black memory bitmap that it draws to. When I call that objects Draw function, the memory bitmap is blitted to the application window. The memory bitmaps are all black to begin with and the object draws on it. Black is the transparent color so it is masked off. The result is an overlay effect.

So, I've been using OR as my logical function in the blt() function and it has worked. But, I've noticed that if the previous layer has painted white, then the layer that draws on top of it comes out looking as if it is beneath the previous layer. The white(ish) colors are the only ones where this effect occurs. All other colors are painted correct (that is, the layer looks like it is painted on top of the previous one and so forth). Has anyone seen this phenomenon?

like image 532
max Avatar asked Feb 27 '26 20:02

max


1 Answers

You're using the wrong function for this. Using a BitBlt with a logical OR will work if the pixel you're trying to overwrite happens to be black, but if you combine two non-zero colours with OR, then you'll get strange results. Try using TransparentBlt instead. That function lets you explicitly specify which colour is supposed to be transparent.

like image 119
Peter Ruderman Avatar answered Mar 01 '26 08:03

Peter Ruderman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!