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

Function fopen_gif_file

win/share/gifread.c:515–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515boolean
516fopen_gif_file(const char *filename, const char *type)
517{
518 int i;
519
520 if (strcmp(type, RDBMODE)) {
521 Fprintf(stderr, "using reading routine for non-reading?\n");
522 return FALSE;
523 }
524 gif_file = fopen(filename, type);
525 if (gif_file == (FILE *) 0) {
526 Fprintf(stderr, "cannot open gif file %s\n", filename);
527 return FALSE;
528 }
529
530 read_header(gif_file);
531 if (GifScreen.Width % TILE_X) {
532 Fprintf(stderr, "error: width %d not divisible by %d\n",
533 GifScreen.Width, TILE_X);
534 exit(EXIT_FAILURE);
535 }
536 tiles_across = GifScreen.Width / TILE_X;
537 curr_tiles_across = 0;
538 if (GifScreen.Height % TILE_Y) {
539 Fprintf(stderr, "error: height %d not divisible by %d\n",
540 GifScreen.Height, TILE_Y);
541 /* exit(EXIT_FAILURE) */;
542 }
543 tiles_down = GifScreen.Height / TILE_Y;
544 curr_tiles_down = 0;
545
546 if (GifScreen.Interlace) {
547 /* sigh -- hope this doesn't happen on micros */
548 image = (pixel **) alloc(GifScreen.Height * sizeof(pixel *));
549 for (i = 0; i < GifScreen.Height; i++) {
550 image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel));
551 }
552 } else {
553 image = (pixel **) alloc(TILE_Y * sizeof(pixel *));
554 for (i = 0; i < TILE_Y; i++) {
555 image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel));
556 }
557 }
558
559 /*
560 ** Initialize the Compression routines
561 */
562 if (!ReadOK(gif_file, &input_code_size, 1)) {
563 Fprintf(stderr, "EOF / read error on image data\n");
564 exit(EXIT_FAILURE);
565 }
566
567 if (LWZReadByte(gif_file, TRUE /*, (int) input_code_size*/ ) < 0) {
568 Fprintf(stderr, "error reading image\n");
569 exit(EXIT_FAILURE);
570 }
571
572 /* read first section */

Callers 1

mainFunction · 0.85

Calls 5

LWZReadByteFunction · 0.85
ReadInterleavedImageFunction · 0.85
ReadTileStripFunction · 0.85
read_headerFunction · 0.70
allocFunction · 0.50

Tested by

no test coverage detected