Click to See Complete Forum and Search --> : BitBlt transparency
Vuen
Jul 29th, 2000, 01:42 AM
How do I blit something making one color (background) transparent?
See This topic (http://forums.vb-world.net/showthread.php?threadid=24204). I explained, in detail how to do this.
Vuen
Jul 31st, 2000, 02:18 PM
Ok, I understand the rest but why does SrcPaint not paint the blackness? And is there a way to do this without a mask, like just paint all except the color RGB(0, 255, 255)? Oh and SrcCopy combines the 2 colors (source and destination pixels), it doesnt paint not whiteness.
http://msdn.microsoft.com/library/wcedoc/wcesdkr/uif_ac_6.htm :
SRCPAINT
Combines the colors of the source and destination rectangles by using the Boolean OR operator.
???
Oh well. Now I have to make a mask version of all my pics.
[Edited by Vuen on 07-31-2000 at 03:39 PM]
Vuen
Jul 31st, 2000, 02:22 PM
Ok but um if I don't have any 255-255-255 colors in my bitmap I dont need to use the mask right?
Hold on I'm trying it...
You would still need to use a Mask regardless of which colours you have. If you don't use a Mask, your picture will either appear darker or watered down.
Mad Compie
Aug 10th, 2000, 01:39 PM
Just copy your background picture to a DC in memory (memDC)
Consider the transparent picture, loop thru x and y and if a dot is found <> transp. colour, put it into memDC with the same x and y
Now your picture is transparent on the chosen background in memory, just put it back with BitBlt() on the Form.
Using memory DC is very very FAST!
Consider also scrolling effects...
Vuen
Sep 4th, 2000, 08:54 PM
Are you sure a memory DC is fast because I don't know if i'm doing something wrong or what but it's SLOW AS HELL AAAAAAAAAAHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!! I use CreateCompatibleDC and CreateCompatibleBitmap and SelectObject the hBitmap into the hDC and then use SetPixelV on the DC. That is slow as hell and it's so frustrating to not be able to pallete a graphic at runtime because of the slowness, so I have to do a GIANT waiting loading time to pallete all the pics like 8 times each for each different pallete I want and well 2500 50x50 pics 8 times each where it does about 5 pics per second is one hell of a load time. I tried experimenting with GetDIBits and stuff but could never get it to work. If you could PLEASE PLEASE TEACHME!!! to use this I would be very greatful..
Mad Compie
Sep 5th, 2000, 01:04 PM
It depends on how you want to use the memDC. I used it for creating transparency on 64x64x16bit pictures and this went faster than using picture boxes.
I also use this to keep painted backgrounds in memory. So if I print something on the background, normally I can't re-print on the same position unless I use the Cls method. But Cls gives us the flickering phenomenon.
So I keep the background image in memory and when I want to print on the same position, I perform a BitBlt around the printed text with the corresponding background area. Then I can print the new line.
When I use this method to perform scrolling numbers (with large fontsize) the flicker seems to dissappear and happens much faster.
/\/\isanThr0p
Sep 6th, 2000, 03:58 PM
You don't need to draw maskpictures.
You can just let your program calculate them and put it into a DC
Vuen
Sep 9th, 2000, 10:19 PM
um guys, THAT DIDNT TELL ME ANYTHING!!!!!!!!!!!!!! You just said "let the program calculate them." What the hell is that! Tell me HOW you got to transparently blit your pictures Mad Compie! Did you use SetPixel?
Mad Compie
Sep 11th, 2000, 02:17 PM
I see you're hungry, Vuen!
Yes indeed I used SetPixel(), but now I found some really interesting algoritm to tile images (like texture backgrounds) and a solid TransBlt function! This TransBlt function works more faster than mine, so I'll give you the link were you can find this zipped file:
http://www.devx.com/free/codelib/view.asp?id=352405
The routines are in a BAS called CUSTOMBLT.BAS.
I hope that your fingernails remain intact by now...
The best way to make a picture transparent is this
Public Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Public Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
if you set nBkMode=1 then the picture is transparent
Mad Compie
Sep 15th, 2000, 01:14 PM
Hmmm, I don't really think so my friend.
If (GetDeviceCaps(hDestDC, CAPS1) And C1_TRANSPARENT) Then
'
' Some NT machines support this *super* simple method!
' Save original settings, Blt, restore settings.
'
OrigMode = SetBkMode(hDestDC, NEWTRANSPARENT)
OrigColor = SetBkColor(hDestDC, TransColor)
Call BitBlt(hDestDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, vbSrcCopy)
Call SetBkColor(hDestDC, OrigColor)
Call SetBkMode(hDestDC, OrigMode)
Else
'...
End If
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.