Wednesday, September 21, 2005

How to create monochrome mask from a bitmap and draw transparent bitmaps to a DC without using TransparentBlt()

To do these, visit this MSDN documentation:

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B79212

Quoted from MSDN, if you wish to create a monochrome bitmap from a color bitmap:
0. Select the bitmap to an 'image DC'
a. Set the background color of the image DC to the color that will be transparent in the bitmap.
b. Create a monochrome DC.
c. BitBlt the image into the monochrome DC.
This will create an AND mask of the bitmap by setting pixels that match the background color to white (1), and setting all other pixels to black (0).

More tutorial on bitmaps and transparent bitmaps:
http://www.codeproject.com/bitmap/gditutorial.asp

More explanation:
When blitting onto a monochrome bitmap from a color, pixels in the source color bitmap that are equal to the background color [of the source color bitmap] are blitted as white. All the remaining pixels are blitted as black.

The code which supports the explanation above:
hbmMask = CreateBitmap(bm.bmWidth,bm.bmHeight,1,1,NULL);
HBITMAP hbmSrcT = SelectObject(hdcSrc,hbmImage);
BITMAP hbmDstT = SelectObject(hdcDst,hbmMask);
SetBkColor(hdcSrc,RGB(255,255,255)); // assume that full white is transparent
BitBlt(hdcDst,0,0,bm.bmWidth,bm.bmHeight,hdcSrc,0,0,SRCCOPY);

3 comments:

Unknown said...

I have a question for the owner of this domain name. Can you please reach out to me? I assume my email address will be attached to this comment. If not, you can reach me at websitepsychiatrist.com/contact-us

Thanks!

Anonymous said...

Hi, I am interested in your domain name: smaco.com
If there is an amount that you would consider selling it?
Contact me to talk more.
monica@monthwork.com

Unknown said...

Please respond to my comment. I am interested in your domain name"smaco.com". I want to talk to you about some details if there is a amount that you would consider selling it
contact me:
lamiakie8@gmail.com