Assumed to be 16-bit (5:6:5).
| 917 | |
| 918 | // Assumed to be 16-bit (5:6:5). |
| 919 | ILboolean 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 | |
| 941 | ILboolean GetAlphaBlock(ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos) |