MCPcopy Create free account
hub / github.com/DentonW/DevIL / ReadGenAttributes

Function ReadGenAttributes

DevIL/src-IL/src/il_psp.cpp:197–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196
197ILboolean ReadGenAttributes()
198{
199 BLOCKHEAD AttHead;
200 ILint Padding;
201 ILuint ChunkLen;
202
203 if (iread(&AttHead, sizeof(AttHead), 1) != 1)
204 return IL_FALSE;
205 UShort(&AttHead.BlockID);
206 UInt(&AttHead.BlockLen);
207
208 if (AttHead.HeadID[0] != 0x7E || AttHead.HeadID[1] != 0x42 ||
209 AttHead.HeadID[2] != 0x4B || AttHead.HeadID[3] != 0x00) {
210 ilSetError(IL_INVALID_FILE_HEADER);
211 return IL_FALSE;
212 }
213 if (AttHead.BlockID != PSP_IMAGE_BLOCK) {
214 ilSetError(IL_INVALID_FILE_HEADER);
215 return IL_FALSE;
216 }
217
218 ChunkLen = GetLittleUInt();
219 if (Header.MajorVersion != 3)
220 ChunkLen -= 4;
221 if (iread(&AttChunk, IL_MIN(sizeof(AttChunk), ChunkLen), 1) != 1)
222 return IL_FALSE;
223
224 // Can have new entries in newer versions of the spec (4.0).
225 Padding = (ChunkLen) - sizeof(AttChunk);
226 if (Padding > 0)
227 iseek(Padding, IL_SEEK_CUR);
228
229 // @TODO: Anything but 24 not supported yet...
230 if (AttChunk.BitDepth != 24 && AttChunk.BitDepth != 8) {
231 ilSetError(IL_INVALID_FILE_HEADER);
232 return IL_FALSE;
233 }
234
235 // @TODO; Add support for compression...
236 if (AttChunk.Compression != PSP_COMP_NONE && AttChunk.Compression != PSP_COMP_RLE) {
237 ilSetError(IL_INVALID_FILE_HEADER);
238 return IL_FALSE;
239 }
240
241 // @TODO: Check more things in the general attributes chunk here.
242
243 return IL_TRUE;
244}
245
246
247ILboolean ParseChunks()

Callers 1

iLoadPspInternalFunction · 0.85

Calls 2

ilSetErrorFunction · 0.85
GetLittleUIntFunction · 0.85

Tested by

no test coverage detected