| Last change
 on this file since 7990 was             829, checked in by bird, 26 years ago | 
        
          | 
gifdraw (gd) v1.2 - initial checkin.
 | 
        
          | File size:
            886 bytes | 
      
      
| Line |  | 
|---|
| 1 | #include <stdio.h> | 
|---|
| 2 | #include <stdlib.h> | 
|---|
| 3 | #include "gd.h" | 
|---|
| 4 |  | 
|---|
| 5 | /* A short program which converts a .gif file into a .gd file, for | 
|---|
| 6 | your convenience in creating images on the fly from a | 
|---|
| 7 | basis image that must be loaded quickly. The .gd format | 
|---|
| 8 | is not intended to be a general-purpose format. */ | 
|---|
| 9 |  | 
|---|
| 10 | int main(int argc, char **argv) | 
|---|
| 11 | { | 
|---|
| 12 | gdImagePtr im; | 
|---|
| 13 | FILE *in, *out; | 
|---|
| 14 | if (argc != 3) { | 
|---|
| 15 | fprintf(stderr, "Usage: giftogd filename.gif filename.gd\n"); | 
|---|
| 16 | exit(1); | 
|---|
| 17 | } | 
|---|
| 18 | in = fopen(argv[1], "rb"); | 
|---|
| 19 | if (!in) { | 
|---|
| 20 | fprintf(stderr, "Input file does not exist!\n"); | 
|---|
| 21 | exit(1); | 
|---|
| 22 | } | 
|---|
| 23 | im = gdImageCreateFromGif(in); | 
|---|
| 24 | fclose(in); | 
|---|
| 25 | if (!im) { | 
|---|
| 26 | fprintf(stderr, "Input is not in GIF format!\n"); | 
|---|
| 27 | exit(1); | 
|---|
| 28 | } | 
|---|
| 29 | out = fopen(argv[2], "wb"); | 
|---|
| 30 | if (!out) { | 
|---|
| 31 | fprintf(stderr, "Output file cannot be written to!\n"); | 
|---|
| 32 | gdImageDestroy(im); | 
|---|
| 33 | exit(1); | 
|---|
| 34 | } | 
|---|
| 35 | gdImageGd(im, out); | 
|---|
| 36 | fclose(out); | 
|---|
| 37 | gdImageDestroy(im); | 
|---|
| 38 |  | 
|---|
| 39 | return 0; | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.