diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
commit | ad547a6b5986815fda458221149728d9d9ab1d87 (patch) | |
tree | 16296910eb3eca724371474ea9aea3994dc69614 /Build/source/libs/gd/libgd-src/examples/tgaread.c | |
parent | 947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff) |
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/examples/tgaread.c')
-rw-r--r-- | Build/source/libs/gd/libgd-src/examples/tgaread.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-src/examples/tgaread.c b/Build/source/libs/gd/libgd-src/examples/tgaread.c new file mode 100644 index 00000000000..859f4d4254b --- /dev/null +++ b/Build/source/libs/gd/libgd-src/examples/tgaread.c @@ -0,0 +1,51 @@ +/* + * You can fetch a set of samples TIFF images here: + * ftp://ftp.remotesensing.org/pub/libtiff/ + * (pics-x.y.z.tar.gz) + */ + +#include <gd.h> +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + gdImagePtr im; + FILE *fp; + char path[4][2048]; + int i; + char dst[2048]; + + sprintf(path[0], "noIconAlpha.tga"); + sprintf(path[1], "noIcon.tga"); + + for (i = 0; i < 2; i++) { + printf("opening %s\n", path[i]); + fp = fopen(path[i], "rb"); + if (!fp) { + printf("failed, cannot open file\n"); + return 1; + } + + im = gdImageCreateFromTga(fp); + fclose(fp); + if (!im) { + fprintf(stderr, "Can't load TIFF image %s\n", path[i]); + return 1; + } + + + sprintf(dst, "%i.png", i); + + fp = fopen(dst, "wb"); + if (!fp) { + fprintf(stderr, "Can't save png image fromtiff.png\n"); + gdImageDestroy(im); + return 1; + } + gdImagePng(im, fp); + fclose(fp); + gdImageDestroy(im); + } + return 0; +} |