|
-
Jul 29th, 2000, 01:42 AM
#1
Thread Starter
Lively Member
How do I blit something making one color (background) transparent?
-
Jul 29th, 2000, 09:38 AM
#2
See This topic. I explained, in detail how to do this.
-
Jul 31st, 2000, 02:18 PM
#3
Thread Starter
Lively Member
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/wc...r/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]
-
Jul 31st, 2000, 02:22 PM
#4
Thread Starter
Lively Member
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...
-
Jul 31st, 2000, 02:37 PM
#5
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.
-
Aug 10th, 2000, 01:39 PM
#6
Fanatic Member
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...
-
Sep 4th, 2000, 08:54 PM
#7
Thread Starter
Lively Member
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..
-
Sep 5th, 2000, 01:04 PM
#8
Fanatic Member
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.
-
Sep 6th, 2000, 03:58 PM
#9
Frenzied Member
You don't need to draw maskpictures.
You can just let your program calculate them and put it into a DC
Sanity is a full time job
Puh das war harter Stoff!
-
Sep 9th, 2000, 10:19 PM
#10
Thread Starter
Lively Member
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?
-
Sep 11th, 2000, 02:17 PM
#11
Fanatic Member
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...
-
Sep 14th, 2000, 02:40 PM
#12
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
-
Sep 15th, 2000, 01:14 PM
#13
Fanatic Member
Hmmm, I don't really think so my friend.
Code:
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
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
|