Internal function to load a raw image
| 69 | |
| 70 | // Internal function to load a raw image |
| 71 | ILboolean iLoadRawInternal() |
| 72 | { |
| 73 | if (iCurImage == NULL) { |
| 74 | ilSetError(IL_ILLEGAL_OPERATION); |
| 75 | return IL_FALSE; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | iCurImage->Width = GetLittleUInt(); |
| 80 | |
| 81 | iCurImage->Height = GetLittleUInt(); |
| 82 | |
| 83 | iCurImage->Depth = GetLittleUInt(); |
| 84 | |
| 85 | iCurImage->Bpp = (ILubyte)igetc(); |
| 86 | |
| 87 | if (iread(&iCurImage->Bpc, 1, 1) != 1) |
| 88 | return IL_FALSE; |
| 89 | |
| 90 | if (!ilTexImage(iCurImage->Width, iCurImage->Height, iCurImage->Depth, iCurImage->Bpp, 0, ilGetTypeBpc(iCurImage->Bpc), NULL)) { |
| 91 | return IL_FALSE; |
| 92 | } |
| 93 | iCurImage->Origin = IL_ORIGIN_LOWER_LEFT; |
| 94 | |
| 95 | // Tries to read the correct amount of data |
| 96 | if (iread(iCurImage->Data, 1, iCurImage->SizeOfData) < iCurImage->SizeOfData) |
| 97 | return IL_FALSE; |
| 98 | |
| 99 | if (ilIsEnabled(IL_ORIGIN_SET)) { |
| 100 | iCurImage->Origin = ilGetInteger(IL_ORIGIN_MODE); |
| 101 | } |
| 102 | else { |
| 103 | iCurImage->Origin = IL_ORIGIN_UPPER_LEFT; |
| 104 | } |
| 105 | |
| 106 | if (iCurImage->Bpp == 1) |
| 107 | iCurImage->Format = IL_LUMINANCE; |
| 108 | else if (iCurImage->Bpp == 3) |
| 109 | iCurImage->Format = IL_RGB; |
| 110 | else // 4 |
| 111 | iCurImage->Format = IL_RGBA; |
| 112 | |
| 113 | return ilFixImage(); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | //! Writes a Raw file |
no test coverage detected