Is it possible to draw bitmaps using masks (AND with the black mask first and then OR with the image) in palettized color systems like mode 13h graphics?
BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, spritemask, 0, 0, vbSrcAnd
'Draw the sprite
BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, sprite, 0, 0, vbSrcPaint
thats how i do it
the mask is your whole character black and the surroundings white, and the other is the character with black all around him. That will let you see through behind him.
Last edited by damasterjo; Nov 19th, 2005 at 11:51 AM.
BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, spritemask, 0, 0, vbSrcAnd
'Draw the sprite
BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, sprite, 0, 0, vbSrcPaint
thats how i do it
the mask is your whole character black and the surroundings white, and the other is the character with black all around him. That will let you see through behind him.
He doesn't use VB dmasterjo and jo0ls. He's a C# / ASM junky
Wouldn't it be best to have a selected color as the trasnparent one? You oughta try working with that.
Yeah, that's the way to go. You just ignore one of the palette colors. I used to always use palette index 255 with some really disturbing color (whichever felt distrurbing at the time).
Ahhh, its ok. It makes no difference that it is a palettised mode. As long as the mask is monochrome between black (0) and white (255), then the color indices work out OK.
I tried many times to have the transp color but I never achieve to have it. How may I do it??
I suppose with Bitblt...?
Would someone please send an example of code?
Thanks a lot!
The image (christmas tree ) has a black area around it which we are treating as transparent (it has the value 0 which points to the background color for the screen in the video hardware) so you can have any background color and this should always work. To draw this image we need to paint the mask first using AND logic, this means that the white area doesn't affect the background pixels on the screen but the black area is erased. Thus when we draw the image on top of the mask (OR logic), we get a nice image of a christmas tree without the black rectangle around it.
I was concerned that this would mess up the indexes but I don't think it will.
wossy, if you code it differently to where you can just have a selected color to be transparent, you wouldn't need any masks. It would be better that way.
In the AWGrafix.inc file there are 3 procedures that draw a bitmap.
DrawImage is just a straight bit block transfer. DrawImageWithLogic lets you select AND / OR / XOR / COPY methods (Using COPY is equivalent to using DrawImage) DrawImageTransparent lets you select a color index that you want to make transparent.
Last edited by wossname; Nov 20th, 2005 at 01:14 PM.