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

Function iReadUnmapTga

DevIL/src-IL/src/il_targa.cpp:332–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330
331
332ILboolean iReadUnmapTga(TARGAHEAD *Header)
333{
334 ILubyte Bpp;
335 char ID[255];
336
337 if (iread(ID, 1, Header->IDLen) != Header->IDLen)
338 return IL_FALSE;
339
340 /*if (Header->Bpp == 16)
341 Bpp = 3;
342 else*/
343 Bpp = (ILubyte)(Header->Bpp >> 3);
344
345 if (!ilTexImage(Header->Width, Header->Height, 1, Bpp, 0, IL_UNSIGNED_BYTE, NULL)) {
346 return IL_FALSE;
347 }
348
349 switch (iCurImage->Bpp)
350 {
351 case 1:
352 iCurImage->Format = IL_COLOUR_INDEX; // wtf? How is this possible?
353 break;
354 case 2: // 16-bit is not supported directly!
355 //iCurImage->Format = IL_RGB5_A1;
356 /*iCurImage->Format = IL_RGBA;
357 iCurImage->Type = IL_UNSIGNED_SHORT_5_5_5_1_EXT;*/
358 //iCurImage->Type = IL_UNSIGNED_SHORT_5_6_5_REV;
359
360 // Remove?
361 //ilCloseImage(iCurImage);
362 //ilSetError(IL_FORMAT_NOT_SUPPORTED);
363 //return IL_FALSE;
364
365 /*iCurImage->Bpp = 4;
366 iCurImage->Format = IL_BGRA;
367 iCurImage->Type = IL_UNSIGNED_SHORT_1_5_5_5_REV;*/
368
369 iCurImage->Format = IL_BGR;
370
371 break;
372 case 3:
373 iCurImage->Format = IL_BGR;
374 break;
375 case 4:
376 iCurImage->Format = IL_BGRA;
377 break;
378 default:
379 ilSetError(IL_INVALID_VALUE);
380 return IL_FALSE;
381 }
382
383
384 // @TODO: Determine this:
385 // We assume that no palette is present, but it's possible...
386 // Should we mess with it or not?
387
388
389 if (Header->ImageType == TGA_UNMAP_COMP) {

Callers 1

iLoadTargaInternalFunction · 0.85

Calls 3

ilSetErrorFunction · 0.85
iUncompressTgaDataFunction · 0.85
i16BitTargaFunction · 0.85

Tested by

no test coverage detected