Reads and writes PNG files. More...
Public Types | |
enum | { PNG_GREYSCALE =0 , PNG_RGB =2 , PNG_INDEXED =3 , PNG_GREYSCALEALPHA =4 , PNG_RGBA =6 } |
Public Member Functions | |
const char * | SeekPNGChunk (InputMemoryStream *pInput, uint32_t uID) |
Scan a PNG file in memory and return pointer to a chunk. | |
const char * | SeekNextPNGChunk (InputMemoryStream *pInput, uint32_t uID) |
Scan a PNG file in memory starting AFTER the previously found chunk and return pointer to a chunk. | |
FilePNG () | |
Default constructor. | |
uint_t | Load (Image *pOutput, InputMemoryStream *pInput) |
Parses a PNG file. | |
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 Attributes | |
static const uint32_t | FILETYPE = 0x504E4720 |
'PNG ' Mac File type for PNG files (Byte swapped on little endian machines) | |
static const uint32_t | AUXTYPE = 0x6F676C65 |
'ogle' Mac creator code for PNG files (Byte swapped on little endian machines) | |
Protected Member Functions | |
const char * | SeekChunk (InputMemoryStream *pInput, uint32_t uID, uintptr_t uStartOffset) |
Scan a PNG file in memory and return pointer to a chunk. | |
Private Attributes | |
RGBAWord8_t | m_Palette [256] |
Palette found in the image. | |
uintptr_t | m_uStartOffset |
PNG file image chunk start offset. | |
uintptr_t | m_uNextOffset |
Offset to the next chunk. | |
uint32_t | m_uChunkSize |
Size of the current chunk in bytes. | |
uint32_t | m_uPNGID |
Untouched ID of the current PNG chunk. | |
Reads and writes PNG files.
This class will read and write out PNG files and use Burger::Image class instances as data transporters
anonymous enum |
Burger::FilePNG::FilePNG | ( | ) |
Default constructor.
Initializes all extra file data to defaults
|
inline |
Get the file image's palette.
Obtain a pointer to the 256 entry RGBA color palette found in the PNG file
|
inline |
Get the file image's palette.
Obtain a constant pointer to the 256 entry RGBA color palette found in the PNG file
uint_t BURGER_API Burger::FilePNG::Load | ( | Image * | pOutput, |
InputMemoryStream * | pInput ) |
Parses a PNG file.
Read in a PNG file and set the extra variables
Will parse 8, 16, 24 and 32 bit compressed PNG 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 PNG file image |
|
protected |
Scan a PNG file in memory and return pointer to a chunk.
pInput | Data stream to read compressed data from |
uID | PNG token to scan for (Must be upper case) |
uStartOffset | Offset into the stream to begin the scan |
const char * Burger::FilePNG::SeekNextPNGChunk | ( | InputMemoryStream * | pInput, |
uint32_t | uID ) |
Scan a PNG file in memory starting AFTER the previously found chunk and return pointer to a chunk.
pInput | Data stream to read compressed data from |
uID | PNG token to scan for (Must be upper case) |
const char * Burger::FilePNG::SeekPNGChunk | ( | InputMemoryStream * | pInput, |
uint32_t | uID ) |
Scan a PNG file in memory and return pointer to a chunk.
pInput | Data stream to read compressed data from |
uID | PNG token to scan for (Must be upper case) |
|
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 PNG 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 PNG 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) |
|
static |
'ogle' Mac creator code for PNG files (Byte swapped on little endian machines)
|
static |
'PNG ' Mac File type for PNG files (Byte swapped on little endian machines)
|
private |
Palette found in the image.
|
private |
Size of the current chunk in bytes.
|
private |
Offset to the next chunk.
|
private |
Untouched ID of the current PNG chunk.
|
private |
PNG file image chunk start offset.