aewarnick Posted June 25, 2003 Posted June 25, 2003 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? Quote C#
*Experts* Volte Posted June 25, 2003 *Experts* Posted June 25, 2003 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. :) Quote
aewarnick Posted June 25, 2003 Author Posted June 25, 2003 Is masking going to limit me to only solid color backgrounds. If so, I can't use it. Quote C#
*Experts* Volte Posted June 25, 2003 *Experts* Posted June 25, 2003 Well, you're pretty much out of luck then... Do you want different *levels* of transparency (i.e. multiple alpha channels?) Perhaps I don't 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? Quote
aewarnick Posted June 25, 2003 Author Posted June 25, 2003 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. Quote C#
*Experts* Volte Posted June 25, 2003 *Experts* Posted June 25, 2003 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 you'll see. :) Quote
Leaders snarfblam Posted June 29, 2003 Leaders Posted June 29, 2003 Just so people know, I looked this up on microsoft.com transparentblit's memory leak was fixed in windows 98 or Me. You COULD use it, it just wouldnt be nice to people using win95. Quote [sIGPIC]e[/sIGPIC]
*Gurus* divil Posted June 30, 2003 *Gurus* Posted June 30, 2003 People using Windows 95 can't use .net anyway. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted June 30, 2003 Author Posted June 30, 2003 Thanks everyone. marble_eater, thanks for posting that info. I'll remember that. Quote C#
*Experts* Volte Posted June 30, 2003 *Experts* Posted June 30, 2003 Windows 98 does contain the memory leak. It was fixed in ME, I believe. Quote
Leaders snarfblam Posted July 1, 2003 Leaders Posted July 1, 2003 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: 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 don't know if this is what aewarnick was looking for Quote [sIGPIC]e[/sIGPIC]
aewarnick Posted July 2, 2003 Author Posted July 2, 2003 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. Quote C#
aewarnick Posted July 4, 2003 Author Posted July 4, 2003 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? Quote C#
Leaders snarfblam Posted July 5, 2003 Leaders Posted July 5, 2003 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) Quote [sIGPIC]e[/sIGPIC]
aewarnick Posted July 5, 2003 Author Posted July 5, 2003 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. Quote C#
Leaders snarfblam Posted July 6, 2003 Leaders Posted July 6, 2003 http://www.rookscape.com/vbgaming/GBeebe/bitblt.php There is a tutorial (for VB6, but you should be able to figure it out for c#) on how to blit a sprite using masks. Quote [sIGPIC]e[/sIGPIC]
aewarnick Posted July 6, 2003 Author Posted July 6, 2003 Thank you m_e. That was a good tutorial. Very graphical. VF's is good too. It is straight forward and to the point. Thank you. Quote C#
Recommended Posts