Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Burger::FileTGA Class Reference

Reads and writes TGA files. More...

Collaboration diagram for Burger::FileTGA:
Collaboration graph
[legend]

Public Types

enum  {
  TGA_NOIMAGE =0 , TGA_RGBINDEXED =1 , TGA_RGB =2 , TGA_GRAY =3 ,
  TGA_RLEINDEXED =9 , TGA_RLERGB =10 , TGA_RLEGRAY =11
}
 

Public Member Functions

uint_t Load (Image *pOutput, InputMemoryStream *pInput)
 Parses a TGA file.
 
const RGBAWord8_tGetPalette (void) const
 Get the file image's palette.
 
RGBAWord8_tGetPalette (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 UnpackPixel8 (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput)
 Decompress 8 bit pixels.
 
static void UnpackPixel16 (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput)
 Decompress 16 bit pixels.
 
static void UnpackPixel24 (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput)
 Decompress 24 bit pixels.
 
static void UnpackPixel32 (uint8_t *pOutput, uintptr_t uOutputLength, InputMemoryStream *pInput)
 Decompress 32 bit pixels.
 

Static Public Attributes

static const uint32_t FILETYPE = 0x54504943
 'TPIC' Mac File type for TGA files (Byte swapped on little endian machines)
 
static const uint32_t AUXTYPE = 0x474B4F4E
 'GKON' Mac creator code for TGA files (Byte swapped on little endian machines)
 

Private Attributes

RGBAWord8_t m_Palette [256]
 Palette found in the image.
 

Detailed Description

Reads and writes TGA files.


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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TGA_NOIMAGE 

Palette only.

TGA_RGBINDEXED 

8 bit uncompressed

TGA_RGB 

RGB uncompressed.

TGA_GRAY 

Grayscale uncompressed.

TGA_RLEINDEXED 

8 bit compressed

TGA_RLERGB 

RGB compressed.

TGA_RLEGRAY 

Grayscale compressed.

Member Function Documentation

◆ GetPalette() [1/2]

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

Get the file image's palette.


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

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

◆ GetPalette() [2/2]

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

Get the file image's palette.


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

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

◆ Load()

uint_t BURGER_API Burger::FileTGA::Load ( Image * pOutput,
InputMemoryStream * pInput )

Parses a TGA file.


Read in a TGA file and set the extra variables

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

Note
A descriptive error message is passed to Debug::Warning()
Parameters
pOutputPointer to an Image record to store the new image into
pInputPointer to a memory stream that has a TGA file image
Returns
Zero for success or non-zero on failure

◆ SetPalette() [1/2]

void Burger::FileTGA::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 TGA 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::FileTGA::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 TGA 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)

◆ UnpackPixel16()

void BURGER_API Burger::FileTGA::UnpackPixel16 ( uint8_t * pOutput,
uintptr_t uOutputLength,
InputMemoryStream * pInput )
static

Decompress 16 bit pixels.


Parameters
pOutputBuffer to accept the decompressed data
uOutputLengthLength of the buffer in uint16_t for decompressed data
pInputData stream to read compressed data from

◆ UnpackPixel24()

void BURGER_API Burger::FileTGA::UnpackPixel24 ( uint8_t * pOutput,
uintptr_t uOutputLength,
InputMemoryStream * pInput )
static

Decompress 24 bit pixels.


Parameters
pOutputBuffer to accept the decompressed data
uOutputLengthLength of the buffer in 24 bit chunks for decompressed data
pInputData stream to read compressed data from

◆ UnpackPixel32()

void BURGER_API Burger::FileTGA::UnpackPixel32 ( uint8_t * pOutput,
uintptr_t uOutputLength,
InputMemoryStream * pInput )
static

Decompress 32 bit pixels.


Parameters
pOutputBuffer to accept the decompressed data
uOutputLengthLength of the buffer in 24 bit chunks for decompressed data
pInputData stream to read compressed data from

◆ UnpackPixel8()

void BURGER_API Burger::FileTGA::UnpackPixel8 ( uint8_t * pOutput,
uintptr_t uOutputLength,
InputMemoryStream * pInput )
static

Decompress 8 bit pixels.


Parameters
pOutputBuffer to accept the decompressed data
uOutputLengthLength of the buffer for decompressed data
pInputData stream to read compressed data from

Member Data Documentation

◆ AUXTYPE

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

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

◆ FILETYPE

const uint32_t Burger::FileTGA::FILETYPE = 0x54504943
static

'TPIC' Mac File type for TGA files (Byte swapped on little endian machines)

◆ m_Palette

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

Palette found in the image.