79 byte pixelDepth, imageDesc;
80 readHeader(tga, imageType, pixelDepth, imageDesc);
81 readData (tga, imageType, pixelDepth, imageDesc);
84 e.
add(
"Failed reading TGA file");
123 if ((width >= 0x8000) || (height >= 0x8000))
143 if (pixelDepth == 24) {
148 }
else if (pixelDepth == 16 || pixelDepth == 32) {
153 }
else if (pixelDepth == 8) {
161 throw Common::Exception(
"Unsupported pixel depth: %d, %d", imageType, pixelDepth);
164 throw Common::Exception(
"Unsupported pixel depth: %d, %d", imageType, pixelDepth);
191 if (pixelDepth == 16) {
202 *dst++ = (pixel & 0x7C00) >> 7;
203 *dst++ = (pixel & 0x03E0) >> 2;
204 *dst++ = (pixel & 0x001F) << 3;
205 *dst++ = (pixel & 0x8000) ? 0xFF : 0x00;
221 while (count-- > 0) {
224 std::memset(data, g, 3);
233 if (imageDesc & 0x20)
239 if (pixelDepth != 24 && pixelDepth != 32)
247 byte length = MIN<uint32>((code & 0x7F) + 1, count);
252 if (pixelDepth == 32) {
256 WRITE_BE_UINT32(data, color);
259 }
else if (pixelDepth == 24) {
271 if (pixelDepth == 32) {
276 }
else if (pixelDepth == 24) {
uint16 readUint16LE()
Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it...
void add(const char *s,...) GCC_PRINTF(2
void readHeader(Common::SeekableReadStream &tga, ImageType &imageType, byte &pixelDepth, byte &imageDesc)
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
void readData(Common::SeekableReadStream &tga, ImageType imageType, byte pixelDepth, byte imageDesc)
bool _isCubeMap
Is this image a cube map? A cube map always needs to have 6 layers!
void resize(typename std::vector< T *>::size_type n, typename std::vector< T *>::value_type val=typename std::vector< T *>::value_type())
Exception that provides a stack of explanations.
Basic exceptions to throw.
Utility templates and functions.
size_t _layerCount
Number of layers in this image.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
PixelFormatRaw _formatRaw
virtual size_t read(void *dataPtr, size_t dataSize)=0
Read data from the stream.
Image related utility functions.
Basic reading stream interfaces.
uint32 readUint32BE()
Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it...
Decoding TGA (TarGa) images.
static void flipVertically(byte *data, int width, int height, int bpp)
Flip an image vertically.
bool isSupportedImageType(ImageType type) const
void load(Common::SeekableReadStream &tga)
Interface for a seekable & readable data stream.
TGA(Common::SeekableReadStream &tga, bool cubeMap=false)
byte readByte()
Read an unsigned byte from the stream and return it.
void readRLE(Common::SeekableReadStream &tga, byte pixelDepth, size_t layer)