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

Function GetBlock

DevIL/src-IL/src/il_dds-save.cpp:919–938  ·  view source on GitHub ↗

Assumed to be 16-bit (5:6:5).

Source from the content-addressed store, hash-verified

917
918// Assumed to be 16-bit (5:6:5).
919ILboolean GetBlock(ILushort *Block, ILushort *Data, ILimage *Image, ILuint XPos, ILuint YPos)
920{
921 ILuint x, y, i = 0, Offset = YPos * Image->Width + XPos;
922
923 for (y = 0; y < 4; y++) {
924 for (x = 0; x < 4; x++) {
925 if (XPos + x < Image->Width && YPos + y < Image->Height)
926 Block[i++] = Data[Offset + x];
927 else
928 // Variant of bugfix from https://sourceforge.net/forum/message.php?msg_id=5486779.
929 // If we are out of bounds of the image, just copy the adjacent data.
930 Block[i++] = Data[Offset];
931 }
932 // We do not want to read past the end of the image.
933 if (YPos + y + 1 < Image->Height)
934 Offset += Image->Width;
935 }
936
937 return IL_TRUE;
938}
939
940
941ILboolean GetAlphaBlock(ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos)

Callers 1

CompressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected