2006-04-05 08:55:57 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-12-22 00:37:35 -08:00
|
|
|
# include "config.h"
|
2006-04-05 08:55:57 -07:00
|
|
|
#endif
|
|
|
|
|
2006-04-05 08:49:38 -07:00
|
|
|
#include <stdio.h>
|
2006-04-05 08:55:57 -07:00
|
|
|
#include "gd.h"
|
2006-04-05 08:49:38 -07:00
|
|
|
|
2013-05-25 10:55:21 -07:00
|
|
|
int main(void)
|
2006-04-05 08:49:38 -07:00
|
|
|
{
|
2007-12-22 00:37:35 -08:00
|
|
|
/* 2.0.22: can't depend on PNG either */
|
|
|
|
char *error;
|
2016-09-03 10:12:58 -07:00
|
|
|
#ifdef HAVE_LIBJPEG
|
2007-12-22 00:37:35 -08:00
|
|
|
FILE *in = 0;
|
2016-09-03 10:12:58 -07:00
|
|
|
#endif
|
2007-12-22 00:37:35 -08:00
|
|
|
FILE *out;
|
|
|
|
gdImagePtr im;
|
|
|
|
int radius;
|
|
|
|
/* Create an image of text on a circle, with an
|
|
|
|
* alpha channel so that we can copy it onto a
|
|
|
|
* background
|
|
|
|
* TBB: 2.0.18: shouldn't depend on JPEG
|
|
|
|
*/
|
2006-04-05 08:50:00 -07:00
|
|
|
#ifdef HAVE_LIBJPEG
|
2007-12-22 00:37:35 -08:00
|
|
|
in = fopen("eleanor.jpg", "rb");
|
|
|
|
if(!in) {
|
|
|
|
im = gdImageCreateTrueColor(300, 300);
|
2013-04-03 05:23:11 -07:00
|
|
|
} else {
|
2007-12-22 00:37:35 -08:00
|
|
|
im = gdImageCreateFromJpeg(in);
|
|
|
|
fclose(in);
|
|
|
|
}
|
2006-04-05 08:50:00 -07:00
|
|
|
#else
|
2007-12-22 00:37:35 -08:00
|
|
|
im = gdImageCreateTrueColor(300, 300);
|
2006-04-05 08:51:53 -07:00
|
|
|
#endif /* HAVE_LIBJPEG */
|
2015-10-30 04:18:54 -07:00
|
|
|
if(!im) {
|
|
|
|
fprintf(stderr, "gdImageCreateTrueColor failed \n");
|
|
|
|
return 1;
|
|
|
|
}
|
2007-12-22 00:37:35 -08:00
|
|
|
if(gdImageSX(im) < gdImageSY(im)) {
|
|
|
|
radius = gdImageSX(im) / 2;
|
|
|
|
} else {
|
|
|
|
radius = gdImageSY(im) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = gdImageStringFTCircle(im,
|
2013-04-03 05:23:11 -07:00
|
|
|
gdImageSX(im) / 2, gdImageSY(im) / 2,
|
|
|
|
radius, radius / 2,
|
|
|
|
0.8, "arial", 24, "top text", "bottom text",
|
|
|
|
gdTrueColorAlpha(192, 100, 255, 32)
|
|
|
|
);
|
2007-12-22 00:37:35 -08:00
|
|
|
if(error) {
|
|
|
|
fprintf(stderr, "gdImageStringFTEx error: %s\n", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
out = fopen("gdfx.png", "wb");
|
|
|
|
if(!out) {
|
|
|
|
fprintf(stderr, "Can't create gdfx.png\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdImagePng(im, out);
|
|
|
|
fclose(out);
|
|
|
|
gdImageDestroy(im);
|
|
|
|
return 0;
|
2006-04-05 08:49:38 -07:00
|
|
|
}
|