I want to select a color to be transparent in a picture. I want to do this using BitBlt or DirectX not using Mask Color. Any help.
Anyone know a good site to help me learn DirectX. I am a beginner.
Printable View
I want to select a color to be transparent in a picture. I want to do this using BitBlt or DirectX not using Mask Color. Any help.
Anyone know a good site to help me learn DirectX. I am a beginner.
Are you any good at advanced math? boolean logic and the like?
It should be possible with BITBLT because all the mask is doing is the hard part of the boolean logic equasions for you.
Beets me tho' the furthest I got was A level stats many years ago
I had that with a Java class. I answered the questions. The tutor got paid...:rolleyes:Quote:
Originally posted by Matt_T_hat
In case it is of any interest to anyone I've been learning VB since the summer. I am now considered the class expert as my questions usually bring in other departments or at least heads of departments before answers are found. College tutors kinda fear me I think.
lol, problem here too.
Anyways, to stick to the topic, Bitblt requires you also to have a mask picture. See more here:
http://vbden.tripod.com/articles/invmask.htm
How about making the yellow color in my picture invisible.Code:BitBlt picDip.hDC, 0, 0, picDip.Width, picDip.Height, picMask(0).hDC, 0, 0, vbSrcAnd
BitBlt picDip.hDC, 0, 0, picDip.Width, picDip.Height, picBlack.hDC, 0, 0, vbSrcPaint
BB.Cls
BitBlt BB.hDC, 0, 0, BB.Width, BB.Height, picMask(1).hDC, 0, 0, vbSrcAnd
BitBlt BB.hDC, 0, 0, BB.Width, BB.Height, picDip.hDC, 0, 0, vbSrcPaint
BitBlt Surface.hDC, 0, 0, Surface.Width, Surface.Height, BB.hDC, 0, 0, vbSrcCopy
Sastraxi, Can you please explain a bit. I am only familiar with SRCCOPY. I understand the white color is not being painted on picDip & BB and in the last paint the color is being painted only on the black surface of BB.
Thank you.
That last technique is used for inverse masking - colour dipping. It makes, say, a green silhouette of the mask on your picture. To do masking, all it takes is two calls:Sorry if I've caused any confusion there.VB Code:
BB.Cls Bitblt BB.hDC, 0, 0, picMask.ScaleWidth, picMask.ScaleHeight, picMask.hDC, 0, 0, vbSrcAnd Bitblt BB.hDC, 0, 0, picMask.ScaleWidth, picMask.ScaleHeight, Surface.hDC, 0, 0, vbSrcPaint
Duh! that change didn't give any output. What about making the blue color in the picture I attached invisible. Anyway I attached my project. Can you please check it out.
Thank you.
Make the BG black. That will solve all your problems. It must be pure black (0,0,0).
Whoops! I think you can change the first to MergePaint, and the second to AND, but keeping the dest. any colour. That's what I said in my tutorial, 'cause someone told me that.
OK that got the white surface in the picture invisible. But what if I want to make any color invisible. Like the sprite control attached (written by Fox). It uses Mask color property, but I want to use BitBlt or DirectX to make it perform faster.
When I get home, I'll try to make it work. Somehow I don't think my BitBlt tutorial is as complete as it should be, maybe I'll start revising it.
I think he knows that, I directed him to my tutorial a bit earlier and I covered that topic.
http://vbden.tripod.com/articles/invmask.htm
Here's a full example on using MergePaint, download the MergePaint.zip that I attached in that thread.
http://www.vbforums.com/showthread.p...hreadid=125073
I've struggled a bit with using getbitmapbits and pixelsV to create a mask in memory on the fly but it's too damn slow for full screen selections. Any words on this you can offer?
Yes- create them beforehand. I know it's really annoying, but it would be best to create them in the same way as you do your other 2D surfaces. You could also use OCX packages that could do this for you in C++ code. Search around for one. The only other alternative is DirectDraw memory access. The masks could be generated that way.
yeah he's right
I got exactly what I wanted at vbexplorer. In this project you don't need a Mask picture.
Too bad it only works with 4-bit & 8-bit pictures.
It uses an API not listed in WinAPI32.txt.
This project has a code found in vbexplorer. It creates the mask picture needed to have transparent background
TransparentBlt leaks memory every time you use it. Don't use it. Do yourself and your end users' favours and remove it from your app. Use a white bg with the mergepaint/and combo, its worth getting rid of memory leaks you'll cause. Ooh, gimme a sec.
WOW I never knew that. Thanks for the warning. :) I guess I just use the mask technique or the Sprite Control.