Results 1 to 22 of 22

Thread: Transparent?...

  1. #1

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    You make a mask of the character, which is another image of the same dimensions as your original. Where you want it to be transparent you make the mask black, and where you want your character to show through you make it white. You first blit the mask but only the white bit by using an AND raster operation (make the last parameter in your your call to BitBlt SrcAnd), then you blit your original image over that using SrcPaint, and it will only copy the image data over where the destination is white.
    Harry.

    "From one thing, know ten thousand things."

  2. #2
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    So ur saying I gotta draw 2 pictures? or is there a operator that does that for me?
    Is there a sample code anywhere? I always learn better by example
    Last edited by invitro; Jan 29th, 2001 at 08:51 PM.
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  3. #3
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    If you have Win98 or higher you can use the TransparentBlt API call....

    Code:
    'This project needs 2 pictureboxes
    'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
    Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Picture1.AutoSize = True
        'API uses pixels
        Picture1.ScaleMode = vbPixels
        Picture2.ScaleMode = vbPixels
    End Sub
    Private Sub Picture2_Paint()
        'If we don't call DoEvents first, our transparent image will be completely wrong
        DoEvents
        TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
    End Sub
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  4. #4
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Thumbs up

    Allright thanks, gonna go try it right now
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  5. #5
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    These API are slow when used with animation. And when using TransparentBlt with Win95, the memory seems to dissapear smoothly...

  6. #6
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    I tried out the TransparentBlt API and it seems to work fine thanks, I just dont know how its gonna handle alot of sprites.

    Maybe I should just make a role playing game so there isent much animation required
    (oppose to a shooter)
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You could always use DirectDraw...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Unhappy

    Yeah I wish i could use direct Draw but i dont know Direct X. I tried experimenting with it and I cant even make a surface. I dont really know any good tutorials that teach Direct X, but I would love to learn it.

    Any suggestions?
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  9. #9
    Lively Member
    Join Date
    Jun 2000
    Posts
    124

    Unhappy transparentblt

    How come transparentblt isn't showing up in my API viewer? I have windows millenium, and I looked in msimg32.dll and found the word transparentblt twice, but my API viewer doesn't list it.
    On Error Resume Screaming...

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The API viewer only shows the functions that were entered into it, it doesn't give info on those available.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    I think the API viewer that comes with VB is for win95 and lower, that way MS don't get a million emails from people saying "How come TransparentBlt doesn't work!!" Here is the declaration....

    Code:
    Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
    Download the API-Guide from www.allapi.net , it has a much larger list of API declaration with examples.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  12. #12
    Lively Member
    Join Date
    Jun 2000
    Posts
    124

    Question

    So there's no way to update my API viewer somehow? Bummer.
    On Error Resume Screaming...

  13. #13
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Sure, just add the above declaration to win32api.txt file (minus the Private keyword) and then it will show up in the API Viewer.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you're using the database conversion (the viewer asks you about it), then you'll need to recreate that afterwards.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15
    Lively Member
    Join Date
    Jun 2000
    Posts
    124

    Cool

    Well, that worked quite handily. Thanks!
    On Error Resume Screaming...

  16. #16
    Guest

    Re: transparentblt

    Originally posted by DarkJedi9
    How come transparentblt isn't showing up in my API viewer? I have windows millenium, and I looked in msimg32.dll and found the word transparentblt twice, but my API viewer doesn't list it.
    Many of the newer function are not listed.

  17. #17
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    They're called UNLISTED APIs.

    They're API calls that work, but have one tiny flaw or bug that makes using other APIs desirable, compared to them. Take TransparentBlt for example. It drains GDI memory, but it does a job that would take a lot of code if it didn't exist. Use these APIs at your own risk.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  18. #18
    Lively Member Spie's Avatar
    Join Date
    Jul 2000
    Location
    On a very small coconut somewhere near Mars
    Posts
    126
    Does anyone have the BitBlt code for the mask? I've been messing around with masks for a while, but with no success...

  19. #19
    Lively Member
    Join Date
    Jun 2000
    Posts
    124

    Cool Yeah...

    Early on in the thread someone mentioned using masks and whatnot. Could anybody provide a bit of code illustrating the concept?
    On Error Resume Screaming...

  20. #20
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Uh, sorry Sastraxi, but TransparentBlt is NOT an undocumented API. It's included in >=Windows98 and this did not exist at the release of VB6.
    But, as YoungBuck said, the API Guide from the KPD team offers enough information about the different API's.
    Unsupported API's have the "SH" prefix or simply just a number prefixed with '#'.

  21. #21
    Guest
    Originally posted by Sastraxi
    [B]They're called UNLISTED APIs.[B]
    TransparentBlt is not unlisted. It's documented in MSDN's Platform SDK.

  22. #22
    Lively Member
    Join Date
    Jun 2000
    Posts
    124

    Cool

    So, um...how 'bout that masking?
    On Error Resume Screaming...

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