Results 1 to 16 of 16

Thread: [RESOLVED] bitmap masking???

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Resolved [RESOLVED] bitmap masking???

    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 don't live here any more.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: bitmap masking???

    I saw this the other day, might help:
    http://www.vbaccelerator.com/codelib/gfx/sprites.htm

  3. #3
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: bitmap masking???

    VB Code:
    1. 'Draw the mask
    2. BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, spritemask, 0, 0, vbSrcAnd
    3. 'Draw the sprite
    4. 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.

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: bitmap masking???

    Quote Originally Posted by damasterjo
    VB Code:
    1. 'Draw the mask
    2. BitBlt form1.hdc, x, y, SpriteWidth, SpriteHeight, spritemask, 0, 0, vbSrcAnd
    3. 'Draw the sprite
    4. 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.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: bitmap masking???

    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).

  6. #6

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: bitmap masking???

    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 don't live here any more.

  7. #7
    Junior Member
    Join Date
    Oct 2005
    Posts
    19

    Transparent color?

    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!

  8. #8
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] bitmap masking???

    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.

  9. #9
    Junior Member
    Join Date
    Oct 2005
    Posts
    19

    Re: [RESOLVED] bitmap masking???

    How can I do it?? Could you write an example of using Dx?

  10. #10
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] bitmap masking???

    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

  11. #11
    Junior Member
    Join Date
    Oct 2005
    Posts
    19

    Re: [RESOLVED] bitmap masking???

    I'm checking it. Thanks a lot, nice !collections of tuts!

  12. #12
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] bitmap masking???

    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

  13. #13

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [RESOLVED] bitmap masking???

    This is how i'm doing the masking in Mode 13h...

    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.
    Attached Images Attached Images  
    I don't live here any more.

  14. #14
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] bitmap masking???

    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.

  15. #15

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [RESOLVED] bitmap masking???

    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.
    Last edited by wossname; Nov 20th, 2005 at 01:14 PM.
    I don't live here any more.

  16. #16
    Junior Member
    Join Date
    Oct 2005
    Posts
    19

    Re: [RESOLVED] bitmap masking???

    Uh? I do I try that instruct?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width