Reads and writes BMP files. More...
Public Types | |
enum | { BMP_RGB =0 , BMP_RLE8 =1 , BMP_RLE4 =2 , BMP_BITFIELDS =3 , BMP_JPEG =4 , BMP_PNG =5 , BMP_ALPHABITFIELDS =6 , BMP_CMYK =11 , BMP_CMYKRLE8 =12 , BMP_CMYKTLE4 =13 } |
Public Member Functions | |
FileBMP () | |
Default constructor. | |
uint_t | Load (Image *pOutput, InputMemoryStream *pInput) |
Parses a BMP file. | |
uint_t | Save (OutputMemoryStream *pOutput, const Image *pImage, uint_t bCompression=0) |
Write an Image structure out as a BMP file image. | |
uint16_t | GetReserved1 (void) const |
Get the file image's first reserved value. | |
void | SetReserved1 (uint16_t uReserved1) |
Set the file image's first reserved value. | |
uint16_t | GetReserved2 (void) const |
Get the file image's second reserved value. | |
void | SetReserved2 (uint16_t uReserved2) |
Set the file image's second reserved value. | |
int32_t | GetXPixelsPerMeter (void) const |
Get the file image's pixels per meter for X. | |
void | SetXPixelsPerMeter (int32_t iXPixelsPerMeter) |
Set the file image's pixels per meter for X. | |
int32_t | GetYPixelsPerMeter (void) const |
Get the file image's pixels per meter for Y. | |
void | SetYPixelsPerMeter (int32_t iYPixelsPerMeter) |
Set the file image's pixels per meter for Y. | |
const RGBAWord8_t * | GetPalette (void) const |
Get the file image's palette. | |
RGBAWord8_t * | GetPalette (void) |
Get the file image's palette. | |
void | SetPalette (const RGBWord8_t *pInput, uint_t uStartIndex=0, uint_t uPaletteSize=256) |
Set the file image's palette (RGB) | |
void | SetPalette (const RGBAWord8_t *pInput, uint_t uStartIndex=0, uint_t uPaletteSize=256) |
Set the file image's palette (RGBA) | |
Static Public Member Functions | |
static void | CompressRLE8 (OutputMemoryStream *pOutput, const uint8_t *pInput, uintptr_t uInputLength, uint_t bSendEOP) |
Take a line of 8 bit pixel data and compress is using the RLE8 format. | |
static const char * | DecompressRLE8 (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput) |
Unpack a single line of RLE data for a BMP file using RLE8 format. | |
Static Public Attributes | |
static const uint32_t | FILETYPE = 0x424D5070 |
'BMPp' Mac File type for BMP files (Byte swapped on little endian machines) | |
static const uint32_t | AUXTYPE = 0x6F676C65 |
'ogle' Mac creator code for BMP files (Byte swapped on little endian machines) | |
static const int32_t | DEFAULT_PIXELS_PER_METER = 2835 |
Default pixels per meter value for BMP files (2834.6472f) | |
Private Attributes | |
uint16_t | m_uReserved1 |
BMP Header reserved field #1. | |
uint16_t | m_uReserved2 |
BMP Header reserved field #2. | |
int32_t | m_iXPixelsPerMeter |
X Pixels per meter. | |
int32_t | m_iYPixelsPerMeter |
Y Pixels per meter. | |
uint32_t | m_uColorsUsed |
Number of colors used. | |
uint32_t | m_uColorsImportant |
Number of important colors. | |
RGBAWord8_t | m_Palette [256] |
Palette found in the image. | |
Reads and writes BMP files.
This class will read and write out BMP files and use Burger::Image class instances as data transporters
anonymous enum |
Burger::FileBMP::FileBMP | ( | ) |
Default constructor.
Initializes all extra file data to defaults
|
static |
Take a line of 8 bit pixel data and compress is using the RLE8 format.
The format itself sucks eggs.
First send a compress token of 0 or a fill count of 1-255 If it's 1-255, then follow the token with the byte to fill with.
If it's zero, then follow it with zero for EOL, 1 for EOP data and 3-FF for raw data (Followed by raw data). Don't use token 2 (Jump)
Since the format needs to know when to send the end of image token, the parameter bSendEOP must be set to TRUE when it's to be sent
pOutput | Pointer to the memory stream to output the compressed bytes into |
pInput | Pointer to a scan line of pixels |
uInputLength | Number of input bytes to process |
bSendEOP | TRUE when sending the last scan line |
|
static |
Unpack a single line of RLE data for a BMP file using RLE8 format.
It's a little strange but here goes...
Grab a byte, if it's not zero then use it as a repeat count and grab the next byte as the fill byte.
If it is zero, then this is an escape code. 0 : end of line 1 : end of data 2 : Delta, get two bytes for a pen move code (Not used) 3-0xFF absolute run (But uint16_t align the source pointer after run)
pOutput | Buffer to accept the decompressed data |
uOutputLength | Length of the buffer for decompressed data |
pInput | Data stream to read compressed data from |
|
inline |
Get the file image's palette.
Obtain a pointer to the 256 entry RGBA color palette found in the BMP file
|
inline |
Get the file image's palette.
Obtain a constant pointer to the 256 entry RGBA color palette found in the BMP file
|
inline |
Get the file image's first reserved value.
Return the BMP file header's first reserved 16 bit value in native endian
|
inline |
Get the file image's second reserved value.
Return the BMP file header's second reserved 16 bit value in native endian
|
inline |
Get the file image's pixels per meter for X.
Return the pixels per meter constant, usually it's 2835 (2834.6472f)
|
inline |
Get the file image's pixels per meter for Y.
Return the pixels per meter constant, usually it's 2835 (2834.6472f)
uint_t BURGER_API Burger::FileBMP::Load | ( | Image * | pOutput, |
InputMemoryStream * | pInput ) |
Parses a BMP file.
Read in a BMP file and set the extra variables
Will parse 16, 24 and 32 bit uncompressed and 8 bit compressed and uncompressed BMP files only. Other formats are not supported
pOutput | Pointer to an Image record to store the new image into |
pInput | Pointer to a memory stream that has a BMP file image |
uint_t Burger::FileBMP::Save | ( | OutputMemoryStream * | pOutput, |
const Image * | pImage, | ||
uint_t | bCompress = 0 ) |
Write an Image structure out as a BMP file image.
Given an image in 8, 15, 16, 24 or 32 bit format, write it out as a BMP file.
8, 15, 24 and 32 bit images are written out without alteration. 16 bit formats will have any alpha data from them stripped, this is a limitation of the BMP file format
pOutput | Pointer to the output stream to store the file image |
pImage | Pointer to a valid Image structure containing the image data |
bCompress | TRUE to apply compression to 8 bit images |
|
inline |
Set the file image's palette (RGBA)
Given a pointer to a palette, copy the colors into this class for writing to an 8 bit BMP file.
If the starting index is greater than 255, this function does nothing. If the color entry count exceeds 256 colors, the remaining colors are ignored to prevent buffer overruns
pInput | Pointer to the palette to copy |
uStartIndex | Color index of the 256 color internal palette to start modification |
uPaletteSize | Number of color entries in the palette (Maximum 256) |
|
inline |
Set the file image's palette (RGB)
Given a pointer to a palette, copy the colors into this class for writing to an 8 bit BMP file. Since the Alpha is missing from the input, each entry set will have the alpha set to zero.
If the starting index is greater than 255, this function does nothing. If the color entry count exceeds 256 colors, the remaining colors are ignored to prevent buffer overruns
pInput | Pointer to the palette to copy |
uStartIndex | Color index of the 256 color internal palette to start modification |
uPaletteSize | Number of color entries in the palette (Maximum 256) |
|
inline |
Set the file image's first reserved value.
Sets the BMP file header's first reserved 16 bit value from native endian
uReserved1 | New first reserved value |
|
inline |
Set the file image's second reserved value.
Sets the BMP file header's second reserved 16 bit value from native endian
uReserved2 | New second reserved value |
|
inline |
Set the file image's pixels per meter for X.
Set the pixels per meter constant
iXPixelsPerMeter | New pixels per meter constant |
|
inline |
Set the file image's pixels per meter for Y.
Set the pixels per meter constant
iYPixelsPerMeter | New pixels per meter constant |
|
static |
'ogle' Mac creator code for BMP files (Byte swapped on little endian machines)
|
static |
Default pixels per meter value for BMP files (2834.6472f)
|
static |
'BMPp' Mac File type for BMP files (Byte swapped on little endian machines)
|
private |
X Pixels per meter.
|
private |
Y Pixels per meter.
|
private |
Palette found in the image.
|
private |
Number of important colors.
|
private |
Number of colors used.
|
private |
BMP Header reserved field #1.
|
private |
BMP Header reserved field #2.