Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::FilePCX Class Reference

Reads and writes PCX files. More...

Collaboration diagram for Burger::FilePCX:

Public Types

enum  { PCX_VERSION25 =0 , PCX_VERSION28 =2 , PCX_VERSION28COLOR =3 , PCX_VERSION30 =5 }
 

Public Member Functions

 FilePCX ()
 Default constructor.
 
ImageLoad (InputMemoryStream *pInput)
 Parses a PCX file.
 
int32_t GetXPixelsPerInch (void) const
 Get the file image's pixels per meter for X.
 
void SetXPixelsPerInch (uint16_t uXPixelsPerInch)
 Set the file image's pixels per meter for X.
 
int32_t GetYPixelsPerInch (void) const
 Get the file image's pixels per meter for Y.
 
void SetYPixelsPerInch (uint16_t uYPixelsPerInch)
 Set the file image's pixels per meter for Y.
 
const RGBAWord8_tGetPalette (void) const
 Get the file image's palette.
 
RGBAWord8_tGetPalette (void)
 Get the file image's palette.
 
const uint8_t * GetEGAPalette (void) const
 Get the file image's EGA palette.
 
uint8_t * GetEGAPalette (void)
 Get the file image's EGA 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 const char * DecompressPCX (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput)
 Decompress PCX bitmap data.
 
static void Merge3Planes (uint8_t *pOutput, const uint8_t *pInput, uintptr_t uWidth)
 Merge a red, green and blue strip.
 

Static Public Attributes

static const uint32_t FILETYPE = 0x50435878
 'PCXx' Mac File type for PCX files (Byte swapped on little endian machines)
 
static const uint32_t AUXTYPE = 0x474B4F4E
 'GKON' Mac creator code for PCX files (Byte swapped on little endian machines)
 
static const uint16_t DEFAULT_PIXELS_PER_INCH = 72
 Default pixels per inch value for PCX files.
 

Private Attributes

uint16_t m_uXPixelsPerInch
 X Pixels per inch (72)
 
uint16_t m_uYPixelsPerInch
 Y Pixels per inch (72)
 
RGBAWord8_t m_Palette [256]
 Palette found in the image.
 
uint8_t m_EGAPalette [48]
 EGA palette.
 

Detailed Description

Reads and writes PCX files.


This routine will take a PCX file image and convert it into an Image structure.

It will handle both compressed 8,15,24 and 32 bit TGA images.

This class will read and write out PCX files and use Burger::Image class instances as data transporters

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
PCX_VERSION25 

File version 2.5.

PCX_VERSION28 

File version 2.8.

PCX_VERSION28COLOR 

File version 2.8 with true color support.

PCX_VERSION30 

File version 3.0.

Constructor & Destructor Documentation

◆ FilePCX()

Burger::FilePCX::FilePCX ( )

Default constructor.


Initializes all extra file data to defaults

Member Function Documentation

◆ DecompressPCX()

const char *BURGER_API Burger::FilePCX::DecompressPCX ( uint8_t * pOutput,
uintptr_t uOutputLength,
InputMemoryStream * pInput )
static

Decompress PCX bitmap data.


The format is simplicity itself.

If the input byte is less than 0xC0, then output the byte. Otherwise and with 0x3F and use it as a count and fill with the next byte.

Opcode 0xC0 does nothing.

Note : When asked to decode an ODD number of pixels, there is a hack to fix a bug in the data overrun buffer. Debabelizer can write out bad PCX files when the width is odd.

Parameters
pOutputBuffer to accept the decompressed data
uOutputLengthLength of the buffer for decompressed data
pInputData stream to read compressed data from
Returns
NULL if success or a pointer to a string describing the error

◆ GetEGAPalette() [1/2]

uint8_t * Burger::FilePCX::GetEGAPalette ( void )
inline

Get the file image's EGA palette.


Obtain a pointer to the 48 byte EGA palette (16 colors, 3 bytes per color)

Returns
Pointer to the 16 entry EGA palette
See also
Burger::FilePCX::GetEGAPalette(void) const

◆ GetEGAPalette() [2/2]

const uint8_t * Burger::FilePCX::GetEGAPalette ( void ) const
inline

Get the file image's EGA palette.


Obtain a constant pointer to the 48 byte EGA palette (16 colors, 3 bytes per color)

Returns
Constant pointer to the 16 entry EGA palette
See also
Burger::FilePCX::GetEGAPalette(void)

◆ GetPalette() [1/2]

RGBAWord8_t * Burger::FilePCX::GetPalette ( void )
inline

Get the file image's palette.


Obtain a pointer to the 256 entry RGBA color palette found in the PCX file

Returns
Pointer to the 256 entry RGBAWord8_t palette
See also
Burger::FilePCX::GetPalette(void) const

◆ GetPalette() [2/2]

const RGBAWord8_t * Burger::FilePCX::GetPalette ( void ) const
inline

Get the file image's palette.


Obtain a constant pointer to the 256 entry RGBA color palette found in the PCX file

Returns
Constant pointer to the 256 entry RGBAWord8_t palette
See also
Burger::FilePCX::GetPalette(void)

◆ GetXPixelsPerInch()

int32_t Burger::FilePCX::GetXPixelsPerInch ( void ) const
inline

Get the file image's pixels per meter for X.


Return the pixels per meter constant, usually it's 2835 (2834.6472f)

Returns
The pixels per meter constant for the X direction
See also
Burger::FilePCX::SetXPixelsPerInch(uint16_t) or Burger::FilePCX::GetYPixelsPerInch(void) const

◆ GetYPixelsPerInch()

int32_t Burger::FilePCX::GetYPixelsPerInch ( void ) const
inline

Get the file image's pixels per meter for Y.


Return the pixels per meter constant, usually it's 2835 (2834.6472f)

Returns
The pixels per meter constant for the Y direction
See also
Burger::FilePCX::SetYPixelsPerInch(uint16_t) or Burger::FilePCX::GetXPixelsPerInch(void) const

◆ Load()

Burger::Image * Burger::FilePCX::Load ( InputMemoryStream * pInput)

Parses a PCX file.


Read in a PCX file and set the extra variables

Will parse 24 bit uncompressed and 8 bit compressed and uncompressed PCX files only. Other formats are not supported

Note
A descriptive error message is passed to Debug::Warning()
Parameters
pInputPointer to a memory stream that has a PCX file image
Returns
A pointer to a valid Image on success or NULL on failure

◆ Merge3Planes()

void BURGER_API Burger::FilePCX::Merge3Planes ( uint8_t * pOutput,
const uint8_t * pInput,
uintptr_t uWidth )
static

Merge a red, green and blue strip.


PCX files interleave an 8 bit per pixel scan line of only red pixels, followed by a line of green and then blue.

This function will merge the three into a strip of RGB triplets

Parameters
pOutputBuffer to receive the RGB triplets
pInputBuffer containing three strips of Red, Green and Blue pixels
uWidthNumber of bytes each strip contains

◆ SetPalette() [1/2]

void Burger::FilePCX::SetPalette ( const RGBAWord8_t * pInput,
uint_t uStartIndex = 0,
uint_t uPaletteSize = 256 )
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 PCX 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

Parameters
pInputPointer to the palette to copy
uStartIndexColor index of the 256 color internal palette to start modification
uPaletteSizeNumber of color entries in the palette (Maximum 256)
See also
SetPalette(const RGBWord8_t *,uint_t,uint_t)

◆ SetPalette() [2/2]

void Burger::FilePCX::SetPalette ( const RGBWord8_t * pInput,
uint_t uStartIndex = 0,
uint_t uPaletteSize = 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 PCX 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

Parameters
pInputPointer to the palette to copy
uStartIndexColor index of the 256 color internal palette to start modification
uPaletteSizeNumber of color entries in the palette (Maximum 256)
See also
SetPalette(const RGBAWord8_t *,uint_t,uint_t)

◆ SetXPixelsPerInch()

void Burger::FilePCX::SetXPixelsPerInch ( uint16_t uXPixelsPerInch)
inline

Set the file image's pixels per meter for X.


Set the pixels per meter constant

Parameters
uXPixelsPerInchNew pixels per meter constant
See also
Burger::FilePCX::DEFAULT_PIXELS_PER_INCH, Burger::FilePCX::GetXPixelsPerInch(void) const or Burger::FilePCX::SetYPixelsPerInch(uint16_t)

◆ SetYPixelsPerInch()

void Burger::FilePCX::SetYPixelsPerInch ( uint16_t uYPixelsPerInch)
inline

Set the file image's pixels per meter for Y.


Set the pixels per meter constant

Parameters
uYPixelsPerInchNew pixels per meter constant
See also
Burger::FilePCX::DEFAULT_PIXELS_PER_INCH, Burger::FilePCX::GetYPixelsPerInch(void) const or Burger::FilePCX::SetXPixelsPerInch(uint16_t)

Member Data Documentation

◆ AUXTYPE

const uint32_t Burger::FilePCX::AUXTYPE = 0x474B4F4E
static

'GKON' Mac creator code for PCX files (Byte swapped on little endian machines)

◆ DEFAULT_PIXELS_PER_INCH

const uint16_t Burger::FilePCX::DEFAULT_PIXELS_PER_INCH = 72
static

Default pixels per inch value for PCX files.

◆ FILETYPE

const uint32_t Burger::FilePCX::FILETYPE = 0x50435878
static

'PCXx' Mac File type for PCX files (Byte swapped on little endian machines)

◆ m_EGAPalette

uint8_t Burger::FilePCX::m_EGAPalette[48]
private

EGA palette.

◆ m_Palette

RGBAWord8_t Burger::FilePCX::m_Palette[256]
private

Palette found in the image.

◆ m_uXPixelsPerInch

uint16_t Burger::FilePCX::m_uXPixelsPerInch
private

X Pixels per inch (72)

◆ m_uYPixelsPerInch

uint16_t Burger::FilePCX::m_uYPixelsPerInch
private

Y Pixels per inch (72)