|
#ifndef _TARGAREADER_H_INCLUDED_
#define _TARGAREADER_H_INCLUDED_
class TargaReader
{
#pragma pack(push) /* push current alignment to stack */
#pragma pack(1) /* set alignment to 1 byte boundary */
class TargaHeader
{
public:
char m_idLength;
char m_colourMapType;
char m_imageType;
short m_colourMapOrigin;
short m_colourMapLength;
char m_colourMapDepth;
short m_xOrigin;
short m_yOrigin;
short m_width;
short m_height;
char m_bitsPerPixel;
char m_imageDescriptor;
};
#pragma pack(pop)
public:
TargaReader();
~TargaReader();
void Load(const string& fileName);
int GetWidth() const
{
return m_targaHeader.m_width;
}
int GetHeight() const
{
return m_targaHeader.m_height;
}
unsigned char* GetRawData()
{
return (unsigned char*)m_pData;
}
int GetBitDepth() const
{
return m_targaHeader.m_bitsPerPixel;
}
private:
void ReadRLE(FILE *pFile);
void ReadRLE16(const char* pDataIn, int bufferInSize, int totalPixels);
void ReadRLE32(const char* pDataIn, int bufferInSize, int totalPixels);
TargaHeader m_targaHeader;
char* m_pData;
int m_dataSize;
};
#endif // _TARGAREADER_H_INCLUDED_
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
After working in the software industry for many years, I've started my own
games company that specialises in strategy games for mobile platforms.