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?
Can't get my head around it.
Printable View
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?
Can't get my head around it.
I saw this the other day, might help:
http://www.vbaccelerator.com/codelib/gfx/sprites.htm
thats how i do itVB Code:
'Draw the mask 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
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 ;)Quote:
Originally Posted by damasterjo
Wouldn't it be best to have a selected color as the trasnparent one? You oughta try working with that. :thumb:
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'll have a demo prepared tomorrow hopefully.
Thanks anyway.
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!
BitBlt is too limited, and doesn't work like that. That's why I use DirectX, where transparency colors are the norm. No mask needed. :thumb:
How can I do it?? Could you write an example of using Dx?
My code might be too advanced for ya. But here's a killer tutorial on it. Enjoy ;)
http://directx4vb.vbgamer.com/Direct...T_DX8Start.asp
I'm checking it. Thanks a lot, nice !collections of tuts!
If you want to check out a couple things from my stuff oughta curiousity, it's in here
www.angelfire.com/fl5/memorydll/index.html
This is how i'm doing the masking in Mode 13h...
The image (christmas tree :D) 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. ;)
True, but this begs the question why use masks in the first place?
Anyway I've dumped a demo in the second post here...
http://www.vbforums.com/showthread.php?p=2249743
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.
Uh? I do I try that instruct?