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

Function channelReadMixed

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

Source from the content-addressed store, hash-verified

358
359
360ILboolean channelReadMixed(ILubyte *scan, ILint width, ILint noCol, ILint *off, ILint bytes)
361{
362 ILint count;
363 int i, j, k;
364 ILubyte col[4];
365
366 for(i = 0; i < width; i += count) {
367 if (ieof())
368 return IL_FALSE;
369
370 count = igetc();
371 if (count == IL_EOF)
372 return IL_FALSE;
373
374 if (count >= 128) { // Repeated sequence
375 if (count == 128) { // Long run
376 count = GetBigUShort();
377 if (ieof()) {
378 ilSetError(IL_FILE_READ_ERROR);
379 return IL_FALSE;
380 }
381 }
382 else
383 count -= 127;
384
385 // We've run past...
386 if ((i + count) > width) {
387 //fprintf(stderr, "ERROR: FF_PIC_load(): Overrun scanline (Repeat) [%d + %d > %d] (NC=%d)\n", i, count, width, noCol);
388 ilSetError(IL_ILLEGAL_FILE_VALUE);
389 return IL_FALSE;
390 }
391
392 for (j = 0; j < noCol; j++)
393 if (iread(&col[j], 1, 1) != 1) {
394 ilSetError(IL_FILE_READ_ERROR);
395 return IL_FALSE;
396 }
397
398 for (k = 0; k < count; k++, scan += bytes) {
399 for (j = 0; j < noCol; j++)
400 scan[off[j]] = col[j];
401 }
402 } else { // Raw sequence
403 count++;
404 if ((i + count) > width) {
405 //fprintf(stderr, "ERROR: FF_PIC_load(): Overrun scanline (Raw) [%d + %d > %d] (NC=%d)\n", i, count, width, noCol);
406 ilSetError(IL_ILLEGAL_FILE_VALUE);
407 return IL_FALSE;
408 }
409
410 for (k = count; k > 0; k--, scan += bytes) {
411 for (j = 0; j < noCol; j++)
412 if (iread(&scan[off[j]], 1, 1) != 1) {
413 ilSetError(IL_FILE_READ_ERROR);
414 return IL_FALSE;
415 }
416 }
417 }

Callers 1

readScanlineFunction · 0.85

Calls 2

GetBigUShortFunction · 0.85
ilSetErrorFunction · 0.85

Tested by

no test coverage detected