MCPcopy Create free account
hub / github.com/NetHack/NetHack / ReadInterleavedImage

Function ReadInterleavedImage

win/share/gifread.c:443–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443static void
444ReadInterleavedImage(FILE *fd, int len, int height)
445{
446 int v;
447 int xpos = 0, ypos = 0, pass = 0;
448
449 while ((v = LWZReadByte(fd, FALSE /*, (int) input_code_size*/ )) >= 0) {
450 PPM_ASSIGN(image[ypos][xpos], ColorMap[CM_RED][v],
451 ColorMap[CM_GREEN][v], ColorMap[CM_BLUE][v]);
452
453 ++xpos;
454 if (xpos == len) {
455 xpos = 0;
456 switch (pass) {
457 case 0:
458 case 1:
459 ypos += 8;
460 break;
461 case 2:
462 ypos += 4;
463 break;
464 case 3:
465 ypos += 2;
466 break;
467 }
468
469 if (ypos >= height) {
470 ++pass;
471 switch (pass) {
472 case 1:
473 ypos = 4;
474 break;
475 case 2:
476 ypos = 2;
477 break;
478 case 3:
479 ypos = 1;
480 break;
481 default:
482 goto fini;
483 }
484 }
485 }
486 if (ypos >= height)
487 break;
488 }
489
490 fini:
491 if (LWZReadByte(fd, FALSE /*, (int) input_code_size*/ ) >= 0)
492 Fprintf(stderr, "too much input data, ignoring extra...\n");
493}
494
495static void
496ReadTileStrip(FILE *fd, int len)

Callers 1

fopen_gif_fileFunction · 0.85

Calls 1

LWZReadByteFunction · 0.85

Tested by

no test coverage detected