Back to index

wims  3.65+svn20090927
giftogd.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "gd.h"
00003 
00004 /* A short program which converts a .gif file into a .gd file, for
00005        your convenience in creating images on the fly from a
00006        basis image that must be loaded quickly. The .gd format
00007        is not intended to be a general-purpose format. */
00008 
00009 int main(int argc, char **argv)
00010 {
00011        gdImagePtr im;
00012        FILE *in, *out;
00013        if (argc != 3) {
00014               fprintf(stderr, "Usage: giftogd filename.gif filename.gd\n");
00015               exit(1);
00016        }
00017        in = fopen(argv[1], "rb");
00018        if (!in) {
00019               fprintf(stderr, "Input file does not exist!\n");
00020               exit(1);
00021        }
00022        im = gdImageCreateFromGif(in);
00023        fclose(in);
00024        if (!im) {
00025               fprintf(stderr, "Input is not in GIF format!\n");
00026               exit(1);
00027        }
00028        out = fopen(argv[2], "wb");
00029        if (!out) {
00030               fprintf(stderr, "Output file cannot be written to!\n");
00031               gdImageDestroy(im);
00032               exit(1);      
00033        }
00034        gdImageGd(im, out);
00035        fclose(out);
00036        gdImageDestroy(im);
00037 }
00038