~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/gd/giftogd.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include "gd.h"
 
3
 
 
4
/* A short program which converts a .gif file into a .gd file, for
 
5
        your convenience in creating images on the fly from a
 
6
        basis image that must be loaded quickly. The .gd format
 
7
        is not intended to be a general-purpose format. */
 
8
 
 
9
int main(int argc, char **argv)
 
10
{
 
11
        gdImagePtr im;
 
12
        FILE *in, *out;
 
13
        if (argc != 3) {
 
14
                fprintf(stderr, "Usage: giftogd filename.gif filename.gd\n");
 
15
                exit(1);
 
16
        }
 
17
        in = fopen(argv[1], "rb");
 
18
        if (!in) {
 
19
                fprintf(stderr, "Input file does not exist!\n");
 
20
                exit(1);
 
21
        }
 
22
        im = gdImageCreateFromGif(in);
 
23
        fclose(in);
 
24
        if (!im) {
 
25
                fprintf(stderr, "Input is not in GIF format!\n");
 
26
                exit(1);
 
27
        }
 
28
        out = fopen(argv[2], "wb");
 
29
        if (!out) {
 
30
                fprintf(stderr, "Output file cannot be written to!\n");
 
31
                gdImageDestroy(im);
 
32
                exit(1);        
 
33
        }
 
34
        gdImageGd(im, out);
 
35
        fclose(out);
 
36
        gdImageDestroy(im);
 
37
}
 
38