diff options
author | pierre <none@none> | 2006-04-05 15:35:53 +0000 |
---|---|---|
committer | pierre <none@none> | 2006-04-05 15:35:53 +0000 |
commit | 084ba37adc6c46cf5536ad11b7dbbeb01364cde1 (patch) | |
tree | 84753c7aca35269a4a96051dc57f3a8568c80abb /src/gd2topng.c | |
parent | ec7d9f2a8062276d8c427e6a9b4ed943d8bf8b23 (diff) | |
download | libgd-084ba37adc6c46cf5536ad11b7dbbeb01364cde1.tar.gz |
- sync to 1.6.0GD_1_6_0
Diffstat (limited to 'src/gd2topng.c')
-rw-r--r-- | src/gd2topng.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gd2topng.c b/src/gd2topng.c new file mode 100644 index 0000000..6d513cc --- /dev/null +++ b/src/gd2topng.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include "gd.h" + +/* A short program which converts a .png file into a .gd file, for + your convenience in creating images on the fly from a + basis image that must be loaded quickly. The .gd format + is not intended to be a general-purpose format. */ + +int main(int argc, char **argv) +{ + gdImagePtr im; + FILE *in, *out; + if (argc != 3) { + fprintf(stderr, "Usage: gd2topng filename.gd2 filename.png\n"); + exit(1); + } + in = fopen(argv[1], "rb"); + if (!in) { + fprintf(stderr, "Input file does not exist!\n"); + exit(1); + } + im = gdImageCreateFromGd2(in); + fclose(in); + if (!im) { + fprintf(stderr, "Input is not in GD2 format!\n"); + exit(1); + } + out = fopen(argv[2], "wb"); + if (!out) { + fprintf(stderr, "Output file cannot be written to!\n"); + gdImageDestroy(im); + exit(1); + } + gdImagePng(im, out); + fclose(out); + gdImageDestroy(im); +} + |