Choosing Device Types for Displaying Bitmaps

One problem you might encounter with bitmaps is that 256-color bitmaps might not display correctly on computers with 4-bit video displays (which can only display 16 colors at a time). One way to get around this problem is by creating a 16-color version of a bitmap to display on computers with 4-bit video displays and a 256-color version of the bitmap to display on computers with 8-bit video displays.

To tell Viewer to display a picture only on a machine with 4-bit or 8-bit video, enter either of the following commands before the bitmap filename in the ew or HDisplayBmp command:

[16color]
[256color]

When you enter the [16color] command, Viewer displays that bitmap only if the user's computer has a 4-bit video display. Similarly, the [256color] command displays the bitmap only if the user's computer has an 8-bit display. For example, the following command (formatted as hidden text in a jump) displays TEST16.DIB only if the user has a 4-bit video display:

!HDisplayBmp(hwndContext, qchPath, "[16color]dibs\\test16.dib", "16-Color Bitmap")

The following command (again, formatted as a jump) displays TEST256.DIB only if the user has an 8-bit video display:

!HDisplayBmp(hwndContext, qchPath, "[256color]dibs\\test256.dib", "256-Color Bitmap")

If the user attempts to display a TEST16.DIB on an 8-bit video display, or a TEST256.DIB on a 4-bit display, Viewer displays an “Unable to display picture” message where the picture would normally appear in the topic. To suppress this message, insert the [nomsg] command before the [16color] or [256color] command, as shown in the following examples:

!HDisplayBmp(hwndContext, qchPath, "[nomsg][16color]dibs\\test16.dib", "16-Color Bitmap")

!HDisplayBmp(hwndContext, qchPath, "[nomsg][256color]dibs\\test256.dib", "256-Color Bitmap")

If two filenames follow a [16color] or [256color] command, Viewer displays the first bitmap if the user has the correct video display or the second bitmap if the user doesn't. For example, the following command displays TEST256.DIB in an embedded window if the user has an 8-bit video display or TEST16.DIB if the user does not:

{ewl MVBMP, ViewerBmp, [256color]dibs.dib dibs.dib}