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

Function i16BitTarga

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

Pretty damn unoptimized

Source from the content-addressed store, hash-verified

491
492// Pretty damn unoptimized
493ILboolean i16BitTarga(ILimage *Image)
494{
495 ILushort *Temp1;
496 ILubyte *Data, *Temp2;
497 ILuint x, PixSize = Image->Width * Image->Height;
498
499 Data = (ILubyte*)ialloc(Image->Width * Image->Height * 3);
500 Temp1 = (ILushort*)Image->Data;
501 Temp2 = Data;
502
503 if (Data == NULL)
504 return IL_FALSE;
505
506 for (x = 0; x < PixSize; x++) {
507 *Temp2++ = (*Temp1 & 0x001F) << 3; // Blue
508 *Temp2++ = (*Temp1 & 0x03E0) >> 2; // Green
509 *Temp2++ = (*Temp1 & 0x7C00) >> 7; // Red
510
511 Temp1++;
512
513
514 /*s = *Temp;
515 s = SwapShort(s);
516 a = !!(s & BIT_15);
517
518 s = s << 1;
519
520 //if (a) {
521 SetBits(s, BIT_0);
522 //}
523
524 //SetBits(s, BIT_15);
525
526 *Temp++ = s;*/
527 }
528
529 if (!ilTexImage(Image->Width, Image->Height, 1, 3, IL_BGR, IL_UNSIGNED_BYTE, Data)) {
530 ifree(Data);
531 return IL_FALSE;
532 }
533
534 ifree(Data);
535
536 return IL_TRUE;
537}
538
539
540//! Writes a Targa file

Callers 1

iReadUnmapTgaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected