Microsoft KB Archive/65557

PRB: Creating Monochrome PM Bitmaps That Are Not Inverted PSS ID Number: Q65557 Article last modified on 09-06-1991 PSS database name: P_PresMan

1.21

OS/2

Summary:

SYMPTOMS Draw into a memory presentation space (PS) and specify a bitcount of 1 (one) to create a monochrome bitmap. If a white rectangle is then drawn, it becomes black in the bitmap. RGB color values are used instead of a color table. Although, the bitmap is inverted (black) on the screen, on some printer devices it does appear correctly.

CAUSE This is one of the stranger behaviors of the system. The following mapping takes place when bitblting a bitmap from monochrome “space” to color “space”. All 0’s (zeros) get mapped to the destination background color and all 1’s (ones) get mapped to the destination foreground color. Since the default destination foreground color is black and the default destination background color is white, this can cause bitmaps to appear “inverted” from what would normally be expected.

RESOLUTION Either of the following options can be used to work around this problem:


 * 1) Set the destination foreground color [by using GpiSetColor or GpiSetAttrs], and set the destination background color [by using GpiSetBackColor or GpiSetAttrs], to be the opposite of their default values.
 * 2) Handle the problem when drawing to the monochrome bitmap.

In the Software/Data Library is a file named MONOBLT that contains a sample application that demonstrates the mapping of monochrome bitmaps to color space. By selecting the first menu item, a small monochrome bitmap is created and filled with two concentric squares. The outside is CLR_TRUE (or 1’s), and the inside is CLR_FALSE (or 0’s).

The bitmap then is blted three times, first with no changes to the default background and foreground colors of the destination PS, then by setting the foreground to white and the background to black in the destination PS, and finally, by setting the foreground to black and the background to white. The results are self-explanatory: the first and last blts are the same, and the middle is inverted.

MONOBLT can be found in the Software/Data Library by searching on the keyword MONOBLT, the Q number of this article, or S12697. MONOBLT was archived using the PKware file-compression utility.

For more information on converting color and monochrome bitmaps, query on the following words:

imagebundle and color and lbackcolor

Copyright Microsoft Corporation 1991.