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

Function iGetOS2Bmp

DevIL/src-IL/src/il_bmp.cpp:726–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724//deleted ilReadRLE4Bmp() USE_POINTER version
725
726ILboolean iGetOS2Bmp(OS2_HEAD *Header)
727{
728 ILuint PadSize, Read, i, j, k, c;
729 ILubyte ByteData;
730
731 if (Header->cBitCount == 1) {
732 if (!ilTexImage(Header->cx, Header->cy, 1, 1, IL_COLOUR_INDEX, IL_UNSIGNED_BYTE, NULL)) {
733 return IL_FALSE;
734 }
735 iCurImage->Origin = IL_ORIGIN_LOWER_LEFT;
736
737 iCurImage->Pal.Palette = (ILubyte*)ialloc(2 * 3);
738 if (iCurImage->Pal.Palette == NULL) {
739 return IL_FALSE;
740 }
741 iCurImage->Pal.PalSize = 2 * 3;
742 iCurImage->Pal.PalType = IL_PAL_BGR24;
743
744 if (iread(iCurImage->Pal.Palette, 1, 2 * 3) != 6)
745 return IL_FALSE;
746
747 PadSize = ((32 - (iCurImage->Width % 32)) / 8) % 4; // Has to truncate.
748 iseek(Header->DataOff, IL_SEEK_SET);
749
750 for (j = 0; j < iCurImage->Height; j++) {
751 Read = 0;
752 for (i = 0; i < iCurImage->Width; ) {
753 if (iread(&ByteData, 1, 1) != 1)
754 return IL_FALSE;
755 Read++;
756 k = 128;
757 for (c = 0; c < 8; c++) {
758 iCurImage->Data[j * iCurImage->Width + i] =
759 (!!(ByteData & k) == 1 ? 1 : 0);
760 k >>= 1;
761 if (++i >= iCurImage->Width)
762 break;
763 }
764 }
765 iseek(PadSize, IL_SEEK_CUR);
766 }
767 return IL_TRUE;
768 }
769
770 if (Header->cBitCount == 4) {
771 if (!ilTexImage(Header->cx, Header->cy, 1, 1, IL_COLOUR_INDEX, IL_UNSIGNED_BYTE, NULL)) {
772 return IL_FALSE;
773 }
774 iCurImage->Origin = IL_ORIGIN_LOWER_LEFT;
775
776 iCurImage->Pal.Palette = (ILubyte*)ialloc(16 * 3);
777 if (iCurImage->Pal.Palette == NULL) {
778 return IL_FALSE;
779 }
780 iCurImage->Pal.PalSize = 16 * 3;
781 iCurImage->Pal.PalType = IL_PAL_BGR24;
782
783 if (iread(iCurImage->Pal.Palette, 1, 16 * 3) != 16*3)

Callers 1

iLoadBitmapInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected