You have two ways to save a bit map that has been created by an application:

GpiQueryBitmapBits copies bit-map data from a memory device context (that has a standard-format bit map selected into it) to a buffer. The bit map you copy can be newly created or have been loaded from a resource file.

You must supply the address in application storage of a bit-map information table. The bit-map information table has the same structure as the bit map information header, except for an additional entry, the colors field. As input to GpiQueryBitmapBits, you supply a bit-count value and a plane value. These must both be standard bit-map format values, so the plane value is always 1, and the bit-count value is 1, 4, 8, or 24. If any conversion of the bit-map data is necessary, it is done automatically. You also must provide the address of the application storage into which the bit-map data is to be loaded. You probably will need to find out how large the bit map is before you can do this. GpiQueryBitmapParameters returns the width, height, plane count, and bit count of a named bit map.

You also must supply the size of the fixed portion of the header (as well as bit count, and so on). Nonstandard formats supported by the device that owns the bit map will also be valid for GpiQueryBitmapBits.

You must ensure that you allocate sufficient storage at the end of the bit map information table for the returned color table which, if the number of planes is 1, will have 2n entries, where n is the number of bits per pel.

On return from GpiQueryBitmapBits, the system supplies the width, height, and bit-map color table in the bit-map information table. You can retrieve a part of a bit map by specifying the number of the scan line from which the transfer is to start, and the number of scan lines you want.

When you have copied a bit map into application storage, you can save the bit map externally, and reload it later, by using OS/2 file-handling functions. After the application creates a file by calling DosOpen, it can call DosWrite to copy the buffer containing the bit-map bits into the file. The application then closes the file by calling DosClose.

If an application needs to use a bit map it has stored on disk, it can copy the file's contents into a buffer by calling DosRead, and then copy information about the image to the bit map by calling GpiSetBitmapBits. The application must select the bit map into a memory device context before it sets the bits. As with GpiQueryBitmapBits, you can transfer a part of the bit map rather than the whole. GpiSetBitmapBits can be used to transfer standard-format bit maps only, and only to a bit map selected into a memory device context. If necessary, bit-map data is automatically converted from one standard format to another. Nonstandard formats supported by the device owning the bit map will also be valid for GpiSetBitmapBits.

If an application creates bit maps another application might use, it should create them by using the standard IBM OS/2 bit-map file format.


[Back] [Next]