PDA

Click to See Complete Forum and Search --> : Transparent?...


HarryW
Jan 29th, 2001, 01:23 AM
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.

invitro
Jan 29th, 2001, 07:31 PM
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 :D

YoungBuck
Jan 29th, 2001, 09:33 PM
If you have Win98 or higher you can use the TransparentBlt API call....



'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: KPDTeam@Allapi.net
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

invitro
Jan 29th, 2001, 11:25 PM
Allright thanks, gonna go try it right now

Mad Compie
Jan 30th, 2001, 12:20 PM
These API are slow when used with animation. And when using TransparentBlt with Win95, the memory seems to dissapear smoothly...

invitro
Jan 30th, 2001, 12:28 PM
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)

parksie
Jan 30th, 2001, 03:09 PM
You could always use DirectDraw... ;)

invitro
Jan 30th, 2001, 05:25 PM
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?

DarkJedi9
Feb 7th, 2001, 03:59 PM
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.

parksie
Feb 7th, 2001, 04:01 PM
The API viewer only shows the functions that were entered into it, it doesn't give info on those available.

YoungBuck
Feb 7th, 2001, 04:04 PM
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....


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.

DarkJedi9
Feb 7th, 2001, 08:35 PM
So there's no way to update my API viewer somehow? Bummer.

YoungBuck
Feb 7th, 2001, 10:36 PM
Sure, just add the above declaration to win32api.txt file (minus the Private keyword) and then it will show up in the API Viewer.

parksie
Feb 8th, 2001, 04:03 AM
If you're using the database conversion (the viewer asks you about it), then you'll need to recreate that afterwards.

DarkJedi9
Feb 8th, 2001, 04:14 PM
Well, that worked quite handily. Thanks!

Feb 8th, 2001, 04:47 PM
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.

Sastraxi
Feb 8th, 2001, 08:14 PM
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.

Spie
Feb 8th, 2001, 08:32 PM
Does anyone have the BitBlt code for the mask? I've been messing around with masks for a while, but with no success...

DarkJedi9
Feb 9th, 2001, 01:48 PM
Early on in the thread someone mentioned using masks and whatnot. Could anybody provide a bit of code illustrating the concept?

Mad Compie
Feb 9th, 2001, 01:55 PM
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 '#'.

Feb 9th, 2001, 02:16 PM
Originally posted by Sastraxi
[B]They're called UNLISTED APIs.[B]

TransparentBlt is not unlisted. It's documented in MSDN's Platform SDK.

DarkJedi9
Feb 9th, 2001, 02:19 PM
So, um...how 'bout that masking?