| 939 | |
| 940 | |
| 941 | ILboolean GetAlphaBlock(ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos) |
| 942 | { |
| 943 | ILuint x, y, i = 0, Offset = YPos * Image->Width + XPos; |
| 944 | |
| 945 | for (y = 0; y < 4; y++) { |
| 946 | for (x = 0; x < 4; x++) { |
| 947 | if (XPos + x < Image->Width && YPos + y < Image->Height) |
| 948 | Block[i++] = Data[Offset + x]; |
| 949 | else |
| 950 | // Variant of bugfix from https://sourceforge.net/forum/message.php?msg_id=5486779. |
| 951 | // If we are out of bounds of the image, just copy the adjacent data. |
| 952 | Block[i++] = Data[Offset]; |
| 953 | } |
| 954 | // We do not want to read past the end of the image. |
| 955 | if (YPos + y + 1 < Image->Height) |
| 956 | Offset += Image->Width; |
| 957 | } |
| 958 | |
| 959 | return IL_TRUE; |
| 960 | } |
| 961 | |
| 962 | ILboolean Get3DcBlock(ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos, int channel) |
| 963 | { |