Note: .Cut support has not been tested yet! A .cut can only have 1 bpp. We need to add support for the .pal's PSP outputs with these...
| 79 | // A .cut can only have 1 bpp. |
| 80 | // We need to add support for the .pal's PSP outputs with these... |
| 81 | ILboolean iLoadCutInternal() |
| 82 | { |
| 83 | CUT_HEAD Header; |
| 84 | ILuint Size, i = 0, j; |
| 85 | ILubyte Count, Run; |
| 86 | |
| 87 | if (iCurImage == NULL) { |
| 88 | ilSetError(IL_ILLEGAL_OPERATION); |
| 89 | return IL_FALSE; |
| 90 | } |
| 91 | |
| 92 | Header.Width = GetLittleShort(); |
| 93 | Header.Height = GetLittleShort(); |
| 94 | Header.Dummy = GetLittleInt(); |
| 95 | |
| 96 | if (Header.Width == 0 || Header.Height == 0) { |
| 97 | ilSetError(IL_INVALID_FILE_HEADER); |
| 98 | return IL_FALSE; |
| 99 | } |
| 100 | |
| 101 | if (!ilTexImage(Header.Width, Header.Height, 1, 1, IL_COLOUR_INDEX, IL_UNSIGNED_BYTE, NULL)) { // always 1 bpp |
| 102 | return IL_FALSE; |
| 103 | } |
| 104 | iCurImage->Origin = IL_ORIGIN_LOWER_LEFT; |
| 105 | |
| 106 | Size = Header.Width * Header.Height; |
| 107 | |
| 108 | while (i < Size) { |
| 109 | Count = igetc(); |
| 110 | if (Count == 0) { // end of row |
| 111 | igetc(); // Not supposed to be here, but |
| 112 | igetc(); // PSP is putting these two bytes here...WHY?! |
| 113 | continue; |
| 114 | } |
| 115 | if (Count & BIT_7) { // rle-compressed |
| 116 | ClearBits(Count, BIT_7); |
| 117 | Run = igetc(); |
| 118 | for (j = 0; j < Count; j++) { |
| 119 | iCurImage->Data[i++] = Run; |
| 120 | } |
| 121 | } |
| 122 | else { // run of pixels |
| 123 | for (j = 0; j < Count; j++) { |
| 124 | iCurImage->Data[i++] = igetc(); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | iCurImage->Origin = IL_ORIGIN_UPPER_LEFT; // Not sure |
| 130 | |
| 131 | /*iCurImage->Pal.Palette = SharedPal.Palette; |
| 132 | iCurImage->Pal.PalSize = SharedPal.PalSize; |
| 133 | iCurImage->Pal.PalType = SharedPal.PalType;*/ |
| 134 | |
| 135 | return ilFixImage(); |
| 136 | } |
| 137 | |
| 138 | /* ????????? |
no test coverage detected