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

Function ReadData

DevIL/src-IL/src/il_dds.cpp:630–678  ·  view source on GitHub ↗

Reads the compressed data

Source from the content-addressed store, hash-verified

628
629// Reads the compressed data
630ILboolean ReadData()
631{
632 ILuint Bps;
633 ILint y, z;
634 ILubyte *Temp;
635
636 if (CompData) {
637 ifree(CompData);
638 CompData = NULL;
639 }
640
641 if (Head.Flags1 & DDS_LINEARSIZE) {
642 //Head.LinearSize = Head.LinearSize * Depth;
643
644 CompData = (ILubyte*)ialloc(Head.LinearSize);
645 if (CompData == NULL) {
646 return IL_FALSE;
647 }
648
649 if (iread(CompData, 1, Head.LinearSize) != (ILuint)Head.LinearSize) {
650 ifree(CompData);
651 CompData = NULL;
652 return IL_FALSE;
653 }
654 }
655 else {
656 Bps = Width * Head.RGBBitCount / 8;
657 CompSize = Bps * Height * Depth;
658
659 CompData = (ILubyte*)ialloc(CompSize);
660 if (CompData == NULL) {
661 return IL_FALSE;
662 }
663
664 Temp = CompData;
665 for (z = 0; z < Depth; z++) {
666 for (y = 0; y < Height; y++) {
667 if (iread(Temp, 1, Bps) != Bps) {
668 ifree(CompData);
669 CompData = NULL;
670 return IL_FALSE;
671 }
672 Temp += Bps;
673 }
674 }
675 }
676
677 return IL_TRUE;
678}
679
680
681ILboolean AllocImage(ILuint CompFormat)

Callers 3

iLoadDdsCubemapInternalFunction · 0.85
iLoadDdsInternalFunction · 0.85
ReadMipmapsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected