enum E_TgaImageOrigin
{
TGA_ORIGIN_BOTTOM_LEFT = 0x00, // bottom left
TGA_ORIGIN_BOTTOM_RIGHT = 0x10, // bottom right
TGA_ORIGIN_TOP_LEFT = 0x20, // top left
TGA_ORIGIN_TOP_RIGHT = 0x30, // top right
};
typedef struct // 18 bytes
{
u8 m_IdLng; // size of image ID field
u8 m_CmapType; // color map type
u8 m_ImageType; // image type
s16 m_Cmap1stEntry; // color map - origin
s16 m_CmapLng; // color map - length
u8 m_CmapEntrySize; // color map - depth of entries
s16 m_OriginX; // X origin of image
s16 m_OriginY; // Y origin of image
u16 m_Width; // width of image
u16 m_Height; // height of image
u8 m_Bpp; // image pixel size
u8 m_ImageDesc; // image descriptor
}
T_HeaderTGA;
//---------------------------------------------------------------------------------------------------------------------
void LoadMappedImageData( u8 const * buff, u8 const * cmap, unsigned int pixSize, unsigned int pixNum, u8 * imgData )
{
unsigned int i, j, idx;
define TGA_HEADER_SIZE 18 // size of TGA file header
define TGA_ORIGIN_MASK 0x30 // origin bit mask ... ImageDesc: bits 5-4
define TGA_ALPHA_MASK 0x0f // alpha bit mask .... ImageDesc: bits 3-0
enum E_TgaCMapType { TGA_CMAP_NONE = 0, // none color map/palette data TGA_CMAP_PRESENT = 1, // with color map/palette };
enum E_TgaImageType { TGA_TYPE_NOIMAGE = 0, // no image data included
};
enum E_TgaImageOrigin { TGA_ORIGIN_BOTTOM_LEFT = 0x00, // bottom left TGA_ORIGIN_BOTTOM_RIGHT = 0x10, // bottom right TGA_ORIGIN_TOP_LEFT = 0x20, // top left TGA_ORIGIN_TOP_RIGHT = 0x30, // top right };
typedef struct // 18 bytes { u8 m_IdLng; // size of image ID field u8 m_CmapType; // color map type u8 m_ImageType; // image type s16 m_Cmap1stEntry; // color map - origin s16 m_CmapLng; // color map - length u8 m_CmapEntrySize; // color map - depth of entries s16 m_OriginX; // X origin of image s16 m_OriginY; // Y origin of image u16 m_Width; // width of image u16 m_Height; // height of image u8 m_Bpp; // image pixel size u8 m_ImageDesc; // image descriptor } T_HeaderTGA;
//--------------------------------------------------------------------------------------------------------------------- void LoadMappedImageData( u8 const * buff, u8 const * cmap, unsigned int pixSize, unsigned int pixNum, u8 * imgData ) { unsigned int i, j, idx;
}
//--------------------------------------------------------------------------------------------------------------------- void LoadRawImageData( u8 const * buff, unsigned int pixSize, unsigned int pixNum, u8 * imgData ) { Memory::Copy( imgData, buff, pixSize * pixNum ); }
//--------------------------------------------------------------------------------------------------------------------- void LoadRLEImageData( u8 const * buff, unsigned int pixSize, unsigned int pixNum, u8 * imgData ) { unsigned int i, j; u8 pckHeader, pckSize, pck[4];
}
//--------------------------------------------------------------------------------------------------------------------- void LoadRLEMappedImageData( u8 const * buff, u8 const * cmap, unsigned int pixSize, unsigned int pixNum, u8 * imgData ) { unsigned int i, j; unsigned char pckHeader, pckSize, pck[4], cmapIdx;
}
// buff, buffLng ... .tga file content & its length //--------------------------------------------------------------------------------------------------------------------- C_Image * C_ImageCodecTGA :: Decode( const u8 \ buff, const unsigned int buffLng ) { // read TGA header data...
// check file type...
// check pixel format...
// load color map...
// decode image data...
// free memory...
// create image...
// flip image...
// return image...
}