#include <stdio.h>
/* If gd.h is not in the search path for includes, specify a full path here */
#include "gd.h"

int main(int argc, char *argv[]) 
{
	/* Declare a pointer to an image. This pointer acts as a "handle"
		through which the image is accessed. */
	gdImagePtr im;

	/* Color indexes. Once set, these values will be used as
		"pens" to draw on the image. */
	int black, white;

	/* The file pointer to which the file will be written. */
	FILE *out;

	/* Create the image. */
	im = gdImageCreate(100, 100);

	/* Allocate the background color (black; red, green, and blue
		values are all zero). The image is always the first argument. */
	black = gdImageColorAllocate(im, 0, 0, 0);

	/* Allocate the foreground color (white; red, green, and blue
		values are all at maximum). */
	white = gdImageColorAllocate(im, 255, 255, 255);

	/* Now draw a solid white rectangle in the middle of the image. */
	gdImageFilledRectangle(im, 25, 25, 74, 74, white);

	/* Almost done: we still have to write the image to a file. 
		Note that the file is opened for writing in binary mode.
		This is crucial under DOS and related operating systems. */
	out = fopen("test.gif", "wb");
	
	/* Write the image to the file in GIF format. */
	gdImageGif(im, out);
	
	/* Close the file. */
	fclose(out);

	/* Destroy the image. This is important in order to return
		memory to the operating system properly! */
	gdImageDestroy(im);

	/* All went well. */
	return 0;
}
