Results 1 to 10 of 10

Thread: BitBlt Transparency... I DON'T GET IT !!!!

  1. #1

    Thread Starter
    Junior Member Cadejos's Avatar
    Join Date
    Dec 2000
    Location
    Costa Rica
    Posts
    29

    Angry BitBlt Transparency... I DON'T GET IT !!!!

    I've just read the thread below, but I still don't get it !!!! RAHHH !!!

    The image that works as a mask is in black & white, where white will be replaced by the original background image, am I right ???

    Ok this part is easy... but when I do the SrcInvert to the other image, the part that has to remain transparent changes color, sometimes brighter.

    The images that I'm trying to merge with the background are ICOs or a BMPs with Magenta where the transparency will take place.

    A little help please.... I´ve already read the section of BitBlt of Fox's but didn't find any clue... (Fox, your page is awesome, what happens here is that I've my mind stuck)

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    If you use the vbSrcAnd and vbSrcPaint for the mask/picture, you will need to have the transparent colour BLACK.

    See here:
    http://vbden.tripod.com/articles/invmask.htm
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Thanks Cadejos, but I dont see where you need vbSrcInvert... the order to blt is:

    BitBlt TheMaske, vbSrcPaint
    BitBlt TheColors, vbSrcAnd

    vbSrcPaint will subtract the colors from the target, and because black is like 0 it does not affect the picture (AnyColor - 0 = AnyColor), while the white part does (AnyColor - White = 0 'Probably less than 0 but we dont care!). What you get is the black mask on the target without any border.

    Now adding the player is likely the same, we just overwrite the black "hole" we just made on the target (0 + AnyColor = AnyColor). The white border wont affect the target - because using vbSrcAnd and white wont do anything

    Apart from this you dont really need to know how this BitBlt transparency works.. it just works and you can make any picture transparent, thats what you need isnt it

    Hope this clears up things a bit..

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It would be And and then Paint Fox, wouldn't it...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Nope.

    First Paint, then And. This is because My original picture has a white BG and the mask is white on black. But yours is the other way around (black bg) *g

    I. Think. I. Know. This. Command. Good. Enough.

  6. #6
    MerryVIP
    Guest
    Hmm? vbSrcPaint first and then vbSrcAnd? I use it in the other way and it works fine...vbSrcAnd paints black color but not white and vbSrcPaint paints all except black.

    I just found out how fast BitBlt really is, I draw 400 graphics per frame (in my test program, each image 50x50 pixels) in full screen (800x600x16) and it's still 10 FPS. Faster than a graphics engine I did with DJGPP, lol

  7. #7

    Thread Starter
    Junior Member Cadejos's Avatar
    Join Date
    Dec 2000
    Location
    Costa Rica
    Posts
    29

    Finally !!!

    Well finally with the tips you all gave me I manage to do it... It took me 4 steps :

    1. BitBlt Mask into Texture_BackGround with vbSrcAnd
    2. Make Inverted Mask into a New Picture Box using vbNotSrcCopy
    3. BitBlt Inverted Mask into Picture (Ico or BMP with magenta)
    using vbSrcAnd
    4. BitBlt the resulting image of step 3 into the resulting image of
    step 1 using vbSrcPaint

    This is working, don´t know if it's the best way of doing it... if one of you know any shortcut let me know... Thank you all again !!!!

  8. #8
    MerryVIP
    Guest
    Humm...Why don't ya just do the drawing directly to the destination picturebox? Then you need only two phases. I see no real point doing inverting, except if you have made white area to be visible and black transparent (in the mask).

  9. #9

    Thread Starter
    Junior Member Cadejos's Avatar
    Join Date
    Dec 2000
    Location
    Costa Rica
    Posts
    29

    I've tried...

    I've tried to follow the instructions that you all gave me (the two phases) but didn't work... for what I saw, the problem is when I do the srcPaint of the picture into the background whith the black area (where it's supposed to copy the image that I want), if I did that whit the Icon image that I previously loaded into a temporaly picturebox, the transparent area of the icon (that has the color of the picturebox -- grey --) will make the background brighter. Then if I did that with the BMP with Magenta color as the transparent area, it will make an strange combination of magenta with the color of the background (that was orange with brown stripes).

    Check out the attatchment, there you can see what happens... If you see anything wrong let me now
    Attached Files Attached Files

  10. #10
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    The background of the sprite MUST be black, in my tut.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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