On December 31, 12: 44: 58 finally completed the program with c to generate a PNG format picture, summarized: 1. Using the function in the GD-1.8.4 image processing library, the main steps are: Create a variable to store blank images -> Matching graphics Colors -> Fill images above color -> Create a PNG Image -> Destroy the image stream to release memory. 2. GD-1.8.4 and 1.8.3 Functions have some different words before each function name, followed by gdimageString (), gdimageChar (), etc. In this function, the parameters have changed, and the parameters of the font indicating the font. "Int font", its value is 1-5, now indicating the parameters of the font becomes "gdfontptr font", gdfontptr is a pointer to the gdfont structure: typef stuct {/ * # of characters in font * / int nchars; / * First Character is Numbered ... (usually 32 = space) * / int offset; / * character width and height * / int w; int h; / * font data; array of character another. Easily incrude in Code, Also Easily Loaded from Data Files. * / Char * Data;} gdfont; / * text functions Take these. * / typedef gdfont * gdfontptr; this represents the font when using GDImageString (), gdimagechar (), etc. The parameters cannot make simple writing 1-5. What should I do? I spent a long time on this issue. Later, I saw him saying a font nchars = 256; Offset = 0; W = 8; H = 15; Data [] = {0, 0, 0, 0, ..... .0, 0, 0,}; I assume these values to a variable of the GDFONTPTR structure, and the result is still not. However, he is inspired by him, I found several files, gdfontg.h, gdfontl.h in the same directory in GD.H. In fact, these documents are all helped us to define a font, GDFONTGIANT, GDFONTLARGE, GDFONTSMALL, etc. Wait. In this case, this means that the font can be written to GDFONTGIANT, GDFONTLARGE, GDFONTSMALL when using GDIMAGESTRING (), gdImageChar (). Probably equivalent to the original number. *********************************************************** ********************************* ^ _ ^, huh, finally got it. The following function generates any string into a png picture of the green bottom red word and adds a certain interference line. #include
IntgetPng (CHAR * STRING, INT STRLEN) {Int Back, Word, Front, Len, SX, SY, I; Char * Str; GDIMAGEPTR NEWIMG; File * PNGFP;
Str = string; len = strn; sx = 10 len * 9; SY = 20; newimg = gdimagecreate (sx, sy); / * Create a variable storage blank image, pixel SX * SY * / PNGFP = FOPNG ("Mypng .png "," wb "); back = gdImageColorAllocate (newimg, 0,255,128); / * color pattern matching * / word = gdImageColorAllocate (newimg, 255,0,128); / * color pattern matching * / front = gdImageColorAllocate (newimg 255, 64, 128); / * Matching graphic color * / gdimagefill (newimg, 0,0, back); / * Filled image to image color * / GDIMAGESTRING (NewImg, GDFONTGIANT, 5, 1, STR, WORD); / * Output string image * / for (i = 0; i