2007-10-07 12:41:52 -07:00
|
|
|
/*
|
|
|
|
* You can fetch a set of samples TIFF images here:
|
2013-04-03 05:23:11 -07:00
|
|
|
* ftp://ftp.remotesensing.org/pub/libtiff/
|
2007-10-07 12:41:52 -07:00
|
|
|
* (pics-x.y.z.tar.gz)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2007-10-08 00:23:20 -07:00
|
|
|
|
2007-10-07 12:41:52 -07:00
|
|
|
int main()
|
|
|
|
{
|
2013-04-03 05:23:11 -07:00
|
|
|
gdImagePtr im;
|
2007-10-07 12:41:52 -07:00
|
|
|
FILE *fp;
|
2007-10-08 00:23:20 -07:00
|
|
|
char path[4][2048];
|
2007-10-07 12:41:52 -07:00
|
|
|
int i;
|
|
|
|
char dst[2048];
|
|
|
|
|
2007-10-08 00:23:20 -07:00
|
|
|
sprintf(path[0], "noIconAlpha.tga");
|
|
|
|
sprintf(path[1], "noIcon.tga");
|
2007-10-07 12:41:52 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-06-21 20:55:11 -07:00
|
|
|
gdImagePng(im, fp);
|
2007-10-07 12:41:52 -07:00
|
|
|
fclose(fp);
|
|
|
|
gdImageDestroy(im);
|
|
|
|
}
|
2013-02-10 19:12:41 -08:00
|
|
|
return 0;
|
2007-10-07 12:41:52 -07:00
|
|
|
}
|