|
-
Jan 29th, 2001, 02:23 AM
#1
Thread Starter
Frenzied Member
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."
-
Jan 29th, 2001, 08:31 PM
#2
Fanatic Member
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? 
-
Jan 29th, 2001, 10:33 PM
#3
Fanatic Member
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}
-
Jan 30th, 2001, 12:25 AM
#4
Fanatic Member
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? 
-
Jan 30th, 2001, 01:20 PM
#5
Fanatic Member
These API are slow when used with animation. And when using TransparentBlt with Win95, the memory seems to dissapear smoothly...
-
Jan 30th, 2001, 01:28 PM
#6
Fanatic Member
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? 
-
Jan 30th, 2001, 04:09 PM
#7
Monday Morning Lunatic
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
-
Jan 30th, 2001, 06:25 PM
#8
Fanatic Member
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? 
-
Feb 7th, 2001, 04:59 PM
#9
Lively Member
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...

-
Feb 7th, 2001, 05:01 PM
#10
Monday Morning Lunatic
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
-
Feb 7th, 2001, 05:04 PM
#11
Fanatic Member
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}
-
Feb 7th, 2001, 09:35 PM
#12
Lively Member
So there's no way to update my API viewer somehow? Bummer.
On Error Resume Screaming...

-
Feb 7th, 2001, 11:36 PM
#13
Fanatic Member
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}
-
Feb 8th, 2001, 05:03 AM
#14
Monday Morning Lunatic
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
-
Feb 8th, 2001, 05:14 PM
#15
Lively Member
Well, that worked quite handily. Thanks!
On Error Resume Screaming...

-
Feb 8th, 2001, 05:47 PM
#16
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.
-
Feb 8th, 2001, 09:14 PM
#17
Good Ol' Platypus
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)
-
Feb 8th, 2001, 09:32 PM
#18
Lively Member
Does anyone have the BitBlt code for the mask? I've been messing around with masks for a while, but with no success...
-
Feb 9th, 2001, 02:48 PM
#19
Lively Member
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...

-
Feb 9th, 2001, 02:55 PM
#20
Fanatic Member
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, 03:16 PM
#21
Originally posted by Sastraxi
[B]They're called UNLISTED APIs.[B]
TransparentBlt is not unlisted. It's documented in MSDN's Platform SDK.
-
Feb 9th, 2001, 03:19 PM
#22
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|