ConvertBMP
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 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 to allow raw data embedded within other file formats to be converted without requiring special conversion routines.
SWIs
SWI ConvertBMP_CreateSpriteFromDIB (&58940)
On entry
R0 = flags :
bit 0: Create sprite, rather than sprite area
Others reserved
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
On exit
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.
The DIB header descriptor has the following format, in C :
/* DIB descriptor passed to the ConvertBMP_CreateSprite call to convert
froma DIB to a sprite. Note this may not be exactly the form stored in
source DIB headers. */
typedef struct {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;
|