Introduction and Overview
The ConvertBMP module provides an ImageFileConvert interface for converting from sprites to BMP files and vice-versa. Because the BMP format does not allow for a mask, conversion from a masked sprite will discard the mask.
Paletted sprites will be converted to paletted BMPs with 4 colour sprites being promoted to 16 colour sprites as the BMP format does not allow for 4 colour images. 16 bit per pixel images will be retained as 15 bit data within the BMP. Not all versions of Windows support this format. CMYK sprites will be converted to 24 bit RGB.
The conversion from BMP to sprite is possible for almost all combinations of BMP data. Non-contiguous bitmaps for RGB data are not supported by the module. Such data formats are allowed by the BMP format but are not supported by any currently available versions of Windows. PNG and JPEG data embedded within BMP images is not supported.
In addition, a single SWI is provided to allow direct conversion from 'DIB' (Device Independent Bitmap) data to sprites. This is intended to allow raw data embedded within other file formats to be converted without requiring special conversion routines.
Technical Details
DIB descriptor
The DIB header descriptor has the following format, in C :
/* DIB descriptor passed to the ConvertBMP_CreateSprite call to convert from
a DIB to a sprite. Note that this may not be exactly the form stored in
source DIB headers. */
typedef struct {
unsigned long dibSize; /* Size of info header in bytes */
unsigned long dibWidth; /* Image width in pixels */
unsigned long dibHeight; /* Image height in pixels */
unsigned short dibPlanes; /* Number of planes Must be 1. */
unsigned short dibBitCount; /* Bits per pixels. Must be 1, 4, 8, 24, 32 */
unsigned long dibCompression; /* Compression type */
unsigned long dibSizeImage; /* Size of image in bytes */
unsigned long dibXPelsPerMeter; /* X pixels per meter */
unsigned long dibYPelsPerMeter; /* Y pixels per meter */
unsigned long dibClrUsed; /* Number of colormap entries (0 == max) */
unsigned long dibClrImportant; /* Number of important colors */
} dibDescriptor;
SWI Calls
| R0 | = | Flags:
| |||||||||
| R1 | = | Pointer to DIB headered data | |||||||||
| R2 | = | Length of DIB headered data | |||||||||
| R3 | = | Pointer to bitmap data, or NULL if bitmap follows the DIB header | |||||||||
| R4 | = | Length of bitmap data | |||||||||
| R5 | = | Pointer to output buffer, or NULL to read size requirements | |||||||||
| R6 | = | Length of output data buffer | |||||||||
| R6 | = | Size of output buffer required, or used |
This SWI is used to convert from a Windows 'Device Independent Bitmap' (DIB) to a sprite (or sprite area). When specified in Windows file formats the bitmap data and the DIB header may not be held together. This function call allows the header and the bitmap data to be referred to independently if desired. If the data is contiguous, as it is within the BMP files, then the bitmap data pointer may be set to 0 and the DIB headered data length set to the full length of the data.