BitBlt draws transparent pieces of Image Blue!!

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
I know how to draw one color of the image transparent with the TransparentBlt api but what about any color in the image that is transparent?
 
Do not use TransparentBlt! It has a fairly bad memory leak in it. The only good GDI32 way to do transparency is with masks.

I wrote 3 (vb6) GDI32 tutorials, the third one covering BitBlt and transparency. You can see it at EliteVB in the Graphics section. :)
 
Well, youre pretty much out of luck then... Do you want different *levels* of transparency (i.e. multiple alpha channels?)

Perhaps I dont know what you mean by "solid color backgrounds". Can you attach the image you want to be made transparent and which sections you want transparent?
 
It could be any image and anywhere on the image. My form that I am drawing the images on is gradient right now but could also be hatched...

If you use DrawImage and have painted the brush in places with Color.FromArgb(0,0,0,0);, those areas would be transparent.
 
Ohhh, I see what you mean. No, you can use gradients *behind* the image. A mask just uses white areas for the parts of your sprite image you want transparent and black areas for the solid bits.

Read the tutorial, and youll see. :)
 
Just so people know, I looked this up on microsoft.com

transparentblits memory leak was fixed in windows 98 or Me. You COULD use it, it just wouldnt be nice to people using win95.
 
Windows 98 does contain the memory leak. It was fixed in ME, I believe.
 
The memory leak was fixed in Me. But i found this when looking up transparentblt on microsoft.com:


Note that this is a VB6 declaration:
Code:
Public Declare Function AlphaBlend _
        Lib "msimg32" _
             (Byval hDcDest As Long, _
              Byval intLeftDest As Integer, _
              Byval intTopDest As Integer, _
              Byval intWidthDest As Integer, _
              Byval intHeightDest As Integer, _
              Byval hDcSource As Long, _
              Byval intLeftSource As Integer, _
              Byval intTopSource As Integer, _
              Byval intWidthSource As Integer, _
              Byval intHeightSource As Integer, _
              Byval lngBlendFunctionStruc As Long) _
              As Long

I dont know if this is what aewarnick was looking for
 
Thanks, m_e, I had already found that though and have been using it. The only problem with it is that it is not the same as TransparentBlt. It fades the whole image. Not just the Transparent parts.

VF already led me to use MaskBlt which will do what I want.

Thank you.
 
I just read in two places that MaskBlt does not work on win98. If that I true, I will need another solution if there is one.

The two sites I saw it on had an alternative but it was very slow. Can anyone think of anything else I could use?
 
You can use bitblt with masks, just blit the mask using the and raster op and then blit the sprite using the or raster op (unless that is the very slow alternative)
 
The sites had methods that involved blitting 7 times. Two times is great! How do you do that? Let me make sure of this...You are not suggesting using MaskBlt are you or is this what VF was talking about? I forgot all about what VF said when I saw MaskBlt.
 
Thank you m_e. That was a good tutorial. Very graphical. VFs is good too. It is straight forward and to the point. Thank you.
 
Back
Top