Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Replacement for MaskBlt

Author: Slater Wold

Date: 00:50:53 03/04/02

Go up one level in this thread


On March 04, 2002 at 03:06:32, James Robertson wrote:

>I suppose a lot of people have wondered why on earth Microsoft decided that only
>Win NT should support the MaskBlt function....
>
>I would like to display masked bitmaps in Win98, doing basically what MaskBlt is
>supposed to do. Is there anyone who can help me find an alternate way to do
>this?
>
>Thanks,
>James

MaskBlt() only works in a 32 bit environment.  If you use it when running a
program that is not 32 bit, it would crash and burn.  That's why.

You need to use BitBlt, but it involves several steps, no easy way like MaskBlt.

The following nine steps describe a process used to draw transparent bitmaps:


1.)Create a DC to hold the image bitmap.


2.) Select the image bitmap into the DC.


3.) Create a memory DC to hold the final image. This is the destination DC.


4.) Copy the portion of the screen that will be covered by the image into the
destination DC.


5.) Create an "AND mask" that contains the mask of the colors to draw (the
nontransparent portions of the image). To do this, perform the following three
steps:

a.) Set the background color of the image DC to the color that will be
transparent in the image.


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).


6.) Use BitBlt with the SRCAND raster operation code to copy the AND mask onto
the destination DC.


7.) Use BitBlt with the SRCAND raster operation code to copy the inverse of the
AND mask onto the image DC.


8.) Use BitBlt with the SRCPAINT raster operation code to copy the image DC onto
the destination DC.


9.) Use BitBlt to copy the contents of the destination DC to the appropriate
portion of the screen.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.