52 m_spritesFile->
cache();
54 m_signature = m_spritesFile->
getU32();
56 m_spritesOffset = m_spritesFile->
tell();
80 fin->
addU32(m_spritesCount);
82 fin->
addU16(m_spritesCount);
85 uint32 spriteAddress = offset + 4 * m_spritesCount;
86 for(
int i = 1; i <= m_spritesCount; i++)
89 for(
int i = 1; i <= m_spritesCount; i++) {
90 m_spritesFile->
seek((i - 1) * 4 + m_spritesOffset);
93 fin->
seek(offset + (i - 1) * 4);
94 fin->
addU32(spriteAddress);
95 fin->
seek(spriteAddress);
97 m_spritesFile->
seek(fromAdress);
104 char spriteData[SPRITE_DATA_SIZE];
105 m_spritesFile->
read(spriteData, dataSize);
106 fin->
write(spriteData, dataSize);
108 spriteAddress = fin->
tell();
115 }
catch(std::exception& e) {
124 m_spritesFile =
nullptr;
131 if(
id == 0 || !m_spritesFile)
134 m_spritesFile->
seek(((
id-1) * 4) + m_spritesOffset);
139 if(spriteAddress == 0)
142 m_spritesFile->
seek(spriteAddress);
145 m_spritesFile->
getU8();
146 m_spritesFile->
getU8();
147 m_spritesFile->
getU8();
153 uint8 *pixels = image->getPixelData();
157 uint8 channels = useAlpha ? 4 : 3;
160 while(read < pixelDataSize && writePos < SPRITE_DATA_SIZE) {
164 for(
int i = 0; i < transparentPixels && writePos < SPRITE_DATA_SIZE; i++) {
165 pixels[writePos + 0] = 0x00;
166 pixels[writePos + 1] = 0x00;
167 pixels[writePos + 2] = 0x00;
168 pixels[writePos + 3] = 0x00;
172 for(
int i = 0; i < coloredPixels && writePos < SPRITE_DATA_SIZE; i++) {
173 pixels[writePos + 0] = m_spritesFile->
getU8();
174 pixels[writePos + 1] = m_spritesFile->
getU8();
175 pixels[writePos + 2] = m_spritesFile->
getU8();
176 pixels[writePos + 3] = useAlpha ? m_spritesFile->
getU8() : 0xFF;
180 read += 4 + (channels * coloredPixels);
184 while(writePos < SPRITE_DATA_SIZE) {
185 pixels[writePos + 0] = 0x00;
186 pixels[writePos + 1] = 0x00;
187 pixels[writePos + 2] = 0x00;
188 pixels[writePos + 3] = 0x00;