00001 #include <stdio.h>
00002 #include "gd.h"
00003 #include "gdfontg.h"
00004 #include "gdfonts.h"
00005
00006 int main(void)
00007 {
00008
00009 FILE *in;
00010 FILE *out;
00011
00012
00013 gdImagePtr im_in, im_out;
00014
00015
00016 gdImagePtr brush;
00017
00018
00019 int white;
00020 int blue;
00021 int red;
00022 int green;
00023
00024
00025 gdPoint points[3];
00026
00027
00028 im_out = gdImageCreate(128, 128);
00029
00030
00031 white = gdImageColorAllocate(im_out, 255, 255, 255);
00032
00033
00034 gdImageColorTransparent(im_out, white);
00035
00036
00037
00038
00039 in = fopen("demoin.gif", "rb");
00040 if (!in) {
00041 fprintf(stderr, "Can't load source image; this demo\n");
00042 fprintf(stderr, "is much more impressive if demoin.gif\n");
00043 fprintf(stderr, "is available.\n");
00044 im_in = 0;
00045 } else {
00046 im_in = gdImageCreateFromGif(in);
00047 fclose(in);
00048
00049 gdImageCopyResized(im_out, im_in,
00050 16, 16, 0, 0, 96, 96, 127, 127);
00051 }
00052 red = gdImageColorAllocate(im_out, 255, 0, 0);
00053 green = gdImageColorAllocate(im_out, 0, 255, 0);
00054 blue = gdImageColorAllocate(im_out, 0, 0, 255);
00055
00056 gdImageLine(im_out, 8, 8, 120, 8, green);
00057 gdImageLine(im_out, 120, 8, 120, 120, green);
00058 gdImageLine(im_out, 120, 120, 8, 120, green);
00059 gdImageLine(im_out, 8, 120, 8, 8, green);
00060
00061 gdImageArc(im_out, 64, 64, 30, 10, 0, 360, blue);
00062
00063 gdImageArc(im_out, 64, 64, 20, 20, 45, 135, blue);
00064
00065 gdImageFill(im_out, 4, 4, blue);
00066
00067 points[0].x = 32;
00068 points[0].y = 0;
00069 points[1].x = 0;
00070 points[1].y = 64;
00071 points[2].x = 64;
00072 points[2].y = 64;
00073 gdImageFilledPolygon(im_out, points, 3, green);
00074
00075 if (im_in) {
00076 int style[8];
00077 brush = gdImageCreate(8, 8);
00078 gdImageCopyResized(brush, im_in,
00079 0, 0, 0, 0,
00080 gdImageSX(brush), gdImageSY(brush),
00081 gdImageSX(im_in), gdImageSY(im_in));
00082 gdImageSetBrush(im_out, brush);
00083
00084
00085 style[0] = 0;
00086 style[1] = 0;
00087 style[2] = 0;
00088 style[3] = 0;
00089 style[4] = 0;
00090 style[5] = 0;
00091 style[6] = 0;
00092 style[7] = 1;
00093 gdImageSetStyle(im_out, style, 8);
00094
00095 gdImageLine(im_out, 0, 127, 127, 0, gdStyledBrushed);
00096 }
00097
00098 gdImageString(im_out, gdFontGiant, 16, 16, (unsigned char *)"hi", red);
00099 gdImageStringUp(im_out, gdFontSmall, 32, 32, (unsigned char *)"hi", red);
00100
00101
00102 gdImageInterlace(im_out, 1);
00103 out = fopen("demoout.gif", "wb");
00104
00105 gdImageGif(im_out, out);
00106 fclose(out);
00107 gdImageDestroy(im_out);
00108 if (im_in) {
00109 gdImageDestroy(im_in);
00110 }
00111 return 0;
00112 }
00113