52 e.
add(
"Failed reading CUR file");
121 if (bitsPerPixel != 8 && bitsPerPixel != 24)
124 const int pitch = width * (bitsPerPixel / 8);
127 byte palette[256 * 4];
129 if (bitsPerPixel == 8)
130 cur.
read(palette, 256 * 4);
134 if (cur.
read(xorMap.
get(), pitch * height) != (pitch * height))
138 const uint32 andWidth = (width + 7) / 8;
140 if (cur.
read(andMap.
get(), andWidth * height) != (andWidth * height))
150 _mipMaps[0]->size = width * height * 4;
154 const byte *xorSrc = xorMap.
get();
157 for (
uint32 y = 0; y < height; y++) {
158 const byte *andSrc = andMap.
get() + andWidth * y;
160 for (
uint32 x = 0; x < width; x++) {
161 if (bitsPerPixel == 8) {
162 const byte pixel = *xorSrc++;
164 *dst++ = palette[pixel * 4];
165 *dst++ = palette[pixel * 4 + 1];
166 *dst++ = palette[pixel * 4 + 2];
173 *dst++ = (andSrc[x / 8] & (1 << (7 - x % 8))) ? 0 : 0xff;
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
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
Exception that provides a stack of explanations.
A simple scoped smart pointer template.
Basic exceptions to throw.
Utility templates and functions.
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.
const Exception kReadError("Read error")
Exception when reading from a stream failed.
Basic reading stream interfaces.
void load(Common::SeekableReadStream &cur)
PointerType get() const
Returns the plain pointer value.
Decoding Windows icon and cursor files (.ICO and .CUR).
WinIconImage(Common::SeekableReadStream &cur)
void readData(Common::SeekableReadStream &cur)
Interface for a seekable & readable data stream.
void readHeader(Common::SeekableReadStream &cur)
byte readByte()
Read an unsigned byte from the stream and return it.