|
-
Aug 13th, 2002, 11:15 AM
#1
Thread Starter
Lively Member
transparency
hi,
i am making a screen saver which has some bubbles bouncing here n there. I have an image of the bubble with a black background. My app also runs with a black background. I want the bubbles to be transparent, coz when two image boxes (of bubbles) overlap each other the one behind is hidden by the one in the front. how can i make the black pixels of the image transparent. i'm not using DirectX and if possible i want to do this without using DirectX.
plz help, thnx in advance.
-
Aug 13th, 2002, 12:09 PM
#2
Frenzied Member
Just use BitBlt
-
Aug 13th, 2002, 03:13 PM
#3
Fanatic Member
Use masking (and bitblt). The sprit (image) should be on a white background, and the mask should be black on white. Then paint the mask to the screen, then and the mask ontop that.
-
Aug 13th, 2002, 11:24 PM
#4
Fanatic Member
why not just have the bubbles in gif format, u could save it with the transparency.
-
Aug 14th, 2002, 10:44 AM
#5
Addicted Member
The problem with saving them as transparant gifs is that when you use the PaintPicture function it will automatically make any transparancy already in the image black. So using gifs is pointless. If you want to stay away from the API, you can do it with straight VB. Here's how:
save the bubble picture with a black background. Then make a mask; save the bubble picture where all color pixels are black and all black pixels are white (thus creating a white background). Then, use the Opcode argument in PaintPicture (it's the last parameter). First blit the mask using "vbSrcAnd" in the Opcode. Then, in the exact same coordinates, blit the regular picture using "vbSrcPaint" in the Opcode. This will produce transparancy and only takes two lines of code, whereas the API takes many more (creating dc's and stuff like that). However, this might be too slow for a screensaver, i don't know.
jmiller
-
Aug 14th, 2002, 07:42 PM
#6
Frenzied Member
You can also use BitBlt without generating the DCs, use the pictureboxes' hDc property... if your game is slow you should try this it's very simple 
VB Code:
'Put this before all of your form code
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC 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 dwRop As Long) As Long
'Now just use it like PaintPicture. The Source DC and Dest DC are the hDc properties of your pictureboxes.
BitBlt ...
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
|