gd-libgd / src / circletexttest.c

#include <stdio.h>
#include <gd.h>

int
main (int argc, char *argv[])
{
	FILE *in = 0;
	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 */
#ifdef HAVE_LIBJPEG
	in = fopen("eleanor.jpg", "rb");
	if (!in) {
		im = gdImageCreateTrueColor(300, 300);
	} else {
		im = gdImageCreateFromJpeg(in);
		fclose(in);
	}
#else
	im = gdImageCreateTrueColor(300, 300);
#endif /* HAVE_LIBJPEG */	
	if (gdImageSX(im) < gdImageSY(im)) {
		radius = gdImageSX(im) / 2;
	} else {
		radius = gdImageSY(im) / 2;
	}
	gdImageStringFTCircle(
		im,
		gdImageSX(im) / 2,
		gdImageSY(im) / 2,
		radius,
		radius / 2,
		0.8,
		"arial",
		24,
		"top text",
		"bottom text",
		gdTrueColorAlpha(192, 100, 255, 32));
	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;
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.