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

Function ReadScanline

DevIL/src-IL/src/il_hdr.cpp:263–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263void ReadScanline(ILubyte *scanline, ILuint w) {
264 ILubyte *runner;
265 ILuint r, g, b, e, read, shift;
266
267 r = igetc();
268 g = igetc();
269 b = igetc();
270 e = igetc();
271
272 //check if the scanline is in the new format
273 //if so, e, r, g, g are stored separated and are
274 //rle-compressed independently.
275 if (r == 2 && g == 2) {
276 ILuint length = (b << 8) | e;
277 ILuint j, t, k;
278 if (length > w)
279 length = w; //fix broken files
280 for (k = 0; k < 4; ++k) {
281 runner = scanline + k;
282 j = 0;
283 while (j < length) {
284 t = igetc();
285 if (t > 128) { //Run?
286 ILubyte val = igetc();
287 t &= 127;
288 //copy current byte
289 while (t > 0 && j < length) {
290 *runner = val;
291 runner += 4;
292 --t;
293 ++j;
294 }
295 }
296 else { //No Run.
297 //read new bytes
298 while (t > 0 && j < length) {
299 *runner = igetc();
300 runner += 4;
301 --t;
302 ++j;
303 }
304 }
305 }
306 }
307 return; //done decoding a scanline in separated format
308 }
309
310 //if we come here, we are dealing with old-style scanlines
311 shift = 0;
312 read = 0;
313 runner = scanline;
314 while (read < w) {
315 if (read != 0) {
316 r = igetc();
317 g = igetc();
318 b = igetc();
319 e = igetc();
320 }

Callers 1

iLoadHdrInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected