# /* Bring in gd library functions */ # #include "gd.h" # # /* Bring in standard I/O so we can output the PNG to a file */ # #include # # int main() { # /* Declare the image */ # gdImagePtr im; # /* Declare output files */ # FILE *pngout, *jpegout; # /* Declare color indexes */ # int black; # int white; # # /* Allocate the image: 640 pixels across by 640 pixels tall */ # im = gdImageCreate(640, 640); # # /* Allocate the color black (red, green and blue all minimum). # Since this is the first color in a new image, it will # be the background color. */ # black = gdImageColorAllocate(im, 0, 0, 0); # # /* Allocate the color white (red, green and blue all maximum). */ # white = gdImageColorAllocate(im, 255, 255, 255); int blue = gdImageColorAllocate(im, 255, 255, 0); # # /* Draw a line from the upper left to the lower right, # using white color index. */ # gdImageLine(im, 0, 0, 639, 639, white); # gdImageArc(im, 100, 250, 50, 50, 0, 360, blue); gdImageFilledArc(im, 250, 250, 50, 50, 0, 360, blue,gdArc); # /* Open a file for writing. "wb" means "write binary", important # under MSDOS, harmless under Unix. */ # pngout = fopen("test.png", "wb"); # # /* Do the same for a JPEG-format file. */ # jpegout = fopen("test.jpg", "wb"); # # /* Output the image to the disk file in PNG format. */ # gdImagePng(im, pngout); # # /* Output the same image in JPEG format, using the default # JPEG quality setting. */ # gdImageJpeg(im, jpegout, -1); # # /* Close the files. */ # fclose(pngout); # fclose(jpegout); # # /* Destroy the image in memory. */ # gdImageDestroy(im); # }