Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with TransparentBlt 2

Status
Not open for further replies.

soas

Technical User
Aug 3, 2001
49
US
I've been trying to use TransparentBlt in a screensaver APP Im making on Visual C++ 6.0, Im using windows 98. My problem has been that it seems to be eating up all my resources eventually freezing my comp or severely affecting its performance.. Im almost positive it isnt a result of how it has been programmed, because using the BitBlt function in its place works without a hitch.. just doesnt do what I want it too, or at least I dont know how to make it do it

One other thing that makes me think its not me is that in the helpfiles for visual c++ 6, it says its peliminary and subject to change and stuff.. so Im guessing its not very well supported or something.

But I've heard that there are ways to put transparent bitmaps using just BitBlt..

Could anyone explain to me how you display transparent bitmaps or show me a place I could go to learn more about it?
 
Soas,

This is a known problem with the TransparentBlt call. It leaks memory in win9x (OK in NT, 2K and XP I think). Go to MSDN and search for TransparentBlt. You should find there official acknowledgement of this bug and, I think, a link to guidance about using BitBlt to draw 'transparent' bitmaps. I can't remember the detail but I think you need about 3 BitBlt calls (each using different raster op codes) to get it to work. It does not however leak memory.

Cheers, Ian.
 
Hi,
I know of 2 methods of tranparent blitting.

Method 1.

Create the bitmap as part of your resources.
Create a black & white mask copy of the bitmap as part of your resources
-where black correspond to the bits of the bitmap you want to see
and white is the transparent part (where the screen background shows through).

Now when you want to put this on the screen:
a. Blit the bitmap to the screen using XOR raster op.
b. Blit the mask to the screen using the AND raster op.
c. Blit the bitmap to the screen using the XOR raster op.


I'll save the second method for some other time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top