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

Function iLoadPicInternal

DevIL/src-IL/src/il_pic.cpp:157–242  ·  view source on GitHub ↗

Internal function used to load the .pic

Source from the content-addressed store, hash-verified

155
156// Internal function used to load the .pic
157ILboolean iLoadPicInternal()
158{
159 ILuint Alpha = IL_FALSE;
160 ILubyte Chained;
161 CHANNEL *Channel = NULL, *Channels = NULL, *Prev;
162 PIC_HEAD Header;
163 ILboolean Read;
164
165 if (iCurImage == NULL) {
166 ilSetError(IL_ILLEGAL_OPERATION);
167 return IL_FALSE;
168 }
169
170 if (!iGetPicHead(&Header))
171 return IL_FALSE;
172 if (!iCheckPic(&Header)) {
173 ilSetError(IL_INVALID_FILE_HEADER);
174 return IL_FALSE;
175 }
176
177 // Read channels
178 do {
179 if (Channel == NULL) {
180 Channel = Channels = (CHANNEL*)ialloc(sizeof(CHANNEL));
181 if (Channels == NULL)
182 return IL_FALSE;
183 }
184 else {
185 Channels->Next = (CHANNEL*)ialloc(sizeof(CHANNEL));
186 if (Channels->Next == NULL) {
187 // Clean up the list before erroring out.
188 while (Channel) {
189 Prev = Channel;
190 Channel = (CHANNEL*)Channel->Next;
191 ifree(Prev);
192 }
193 return IL_FALSE;
194 }
195 Channels = (CHANNEL*)Channels->Next;
196 }
197 Channels->Next = NULL;
198
199 Chained = igetc();
200 Channels->Size = igetc();
201 Channels->Type = igetc();
202 Channels->Chan = igetc();
203 if (ieof()) {
204 Read = IL_FALSE;
205 goto finish;
206 }
207
208 // See if we have an alpha channel in there
209 if (Channels->Chan & PIC_ALPHA_CHANNEL)
210 Alpha = IL_TRUE;
211
212 } while (Chained);
213
214 if (Alpha) { // Has an alpha channel

Callers 2

ilLoadPicFFunction · 0.85
ilLoadPicLFunction · 0.85

Calls 5

ilSetErrorFunction · 0.85
iGetPicHeadFunction · 0.85
iCheckPicFunction · 0.85
readScanlinesFunction · 0.85
ilFixImageFunction · 0.85

Tested by

no test coverage detected