index.html
来自「CA仿真模型中SLEUTH模型」· HTML 代码 · 共 1,606 行 · 第 1/5 页
HTML
1,606 行
<A HREF="#gdImageLine">gdImageLine</A> function with thespecial color value <A HREF="#gdStyled">gdStyled</A>.<P>As of <A HREF="#whatsnew1.1.1">version 1.1.1</A>, the stylearray is copied when you set the style, so you need notbe concerned with keeping the array around indefinitely.This should not break existing code that assumes stylesare not copied.<P>You can also combine styles and brushes to draw the brushimage at intervals instead of in a continuous stroke. When creating a style for use with a brush, thestyle values are interpreted differently: zero (0) indicatespixels at which the brush should not be drawn, while one (1) indicates pixels at which the brush should be drawn. To draw a styled, brushed line, you must use thespecial color value <A HREF="#gdStyledBrushed">gdStyledBrushed</A>. For an example of this featurein use, see gddemo.c (provided in the distribution).<PRE><A HREF="#gdImagePtr">gdImagePtr</A> im;int styleDotted[2], styleDashed[6];FILE *in;int black;int red;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0); red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0); /* Set up dotted style. Leave every other pixel alone. */styleDotted[0] = red;styleDotted[1] = gdTransparent;/* Set up dashed style. Three on, three off. */styleDashed[0] = red;styleDashed[1] = red;styleDashed[2] = red;styleDashed[3] = gdTransparent;styleDashed[4] = gdTransparent;styleDashed[5] = gdTransparent;/* Set dotted style. Note that we have to specify how many pixels are in the style! */gdImageSetStyle(im, styleDotted, 2);/* Draw a line from the upper left corner to the lower right corner. */<A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdStyled">gdStyled</A>);/* Now the dashed line. */gdImageSetStyle(im, styleDashed, 6);<A HREF="#gdImageLine">gdImageLine</A>(im, 0, 99, 0, 99, <A HREF="#gdStyled">gdStyled</A>);/* ... Do something with the image, such as saving it to a file ... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE></DL><H3><A NAME="query">Query Functions</A></H3><DL><DT><A NAME="gdImageBlue">int gdImageBlue(gdImagePtr im, int color)</A><STRONG>(MACRO)</STRONG> <DD>gdImageBlue is a macro which returns the blue component ofthe specified color index. Use this macro rather than accessing thestructure members directly.<DT><A NAME="gdImageGetPixel">int gdImageGetPixel(gdImagePtr im, int x, int y)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageGetPixel() retrieves the color index of a particularpixel. Always use this function to query pixels;do not access the pixels of the <A HREF="#gdImage">gdImage</A> structure directly.<PRE>... inside a function ...FILE *in;gdImagePtr im;int c;in = fopen("mygif.gif", "rb");im = <A HREF="#gdImageCreateFromGif">gdImageCreateFromGif</A>(in);fclose(in);c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);printf("The value of the center pixel is %d; RGB values are %d,%d,%d\n", c, im->red[c], im->green[c], im->blue[c]);<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE> <DT><A NAME="gdImageBoundsSafe">int gdImageBoundsSafe(gdImagePtr im, int x, int y)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageBoundsSafe returns true (1) if the specified point is within the boundsof the image, false (0) if not. This function is intended primarily for use by those who wish to add functions to gd. All of the gd drawing functions already clip safely to the edges of the image.<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);if (gdImageBoundsSafe(im, 50, 50)) { printf("50, 50 is within the image bounds\n");} else { printf("50, 50 is outside the image bounds\n");}<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageGreen">int gdImageGreen(gdImagePtr im, int color)</A><STRONG>(MACRO)</STRONG> <DD>gdImageGreen is a macro which returns the green component ofthe specified color index. Use this macro rather than accessing thestructure members directly.<DT><A NAME="gdImageRed">int gdImageRed(gdImagePtr im, int color)</A><STRONG>(MACRO)</STRONG> <DD>gdImageRed is a macro which returns the red component ofthe specified color index. Use this macro rather than accessing thestructure members directly.<DT><A NAME="gdImageSX">int gdImageSX(gdImagePtr im)</A><STRONG>(MACRO)</STRONG> <DD>gdImageSX is a macro which returns the width of the imagein pixels. Use this macro rather than accessing thestructure members directly.<DT><A NAME="gdImageSY">int gdImageSY(gdImagePtr im)</A><STRONG>(MACRO)</STRONG> <DD>gdImageSY is a macro which returns the height of the imagein pixels. Use this macro rather than accessing thestructure members directly.</DL><H3><A NAME="fonts">Fonts and text-handling functions</A></H3><DL><DT><A NAME="gdImageChar">void gdImageChar(gdImagePtr im, gdFontPtr font, int x, int y, int c, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageChar is used to draw single characters on the image.(To draw multiple characters, use <A HREF="#gdImageString">gdImageString</A>.) The second argument is apointer to a font definition structure; five fonts areprovided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,gdFontLarge, and gdFontGiant. You mustinclude the files "gdfontt.h", "gdfonts.h", "gdfontmb.h","gdfontl.h" and "gdfontg.h" respectivelyand (if you are not using a library-based approach) link with the corresponding .c files to use the provided fonts.The character specified by the fifthargument is drawn from left to right in the specified color. (See <A HREF="#gdImageCharUp">gdImageCharUp</A> for a wayof drawing vertical text.) Pixels notset by a particular character retain their previous color. <PRE>#include "gd.h"#include "gdfontl.h"... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0); /* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255); /* Draw a character. */gdImageChar(im, gdFontLarge, 0, 0, 'Q', white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageCharUp">void gdImageCharUp(gdImagePtr im, gdFontPtr font, int x, int y, int c, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageCharUp is used to draw single characters on the image,rotated 90 degrees.(To draw multiple characters, use <A HREF="#gdImageStringUp">gdImageStringUp</A>.) The second argument is apointer to a font definition structure; five fonts areprovided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,gdFontLarge, and gdFontGiant. You mustinclude the files "gdfontt.h", "gdfonts.h", "gdfontmb.h","gdfontl.h" and "gdfontg.h" respectivelyand (if you are not using a library-based approach) link with the corresponding .c files to use the provided fonts. The character specified by the fifth argument is drawn from bottom to top, rotated at a 90-degree angle, in the specified color. (See <A HREF="#gdImageChar">gdImageChar</A> for a wayof drawing horizontal text.) Pixels notset by a particular character retain their previous color. <PRE>#include "gd.h"#include "gdfontl.h"... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0); /* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255); /* Draw a character upwards so it rests against the top of the image. */gdImageCharUp(im, gdFontLarge, 0, gdFontLarge->h, 'Q', white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageString">void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, char *s, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageString is used to draw multiple characters on the image.(To draw single characters, use <A HREF="#gdImageChar">gdImageChar</A>.) The second argument is apointer to a font definition structure; five fonts areprovided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,gdFontLarge, and gdFontGiant. You mustinclude the files "gdfontt.h", "gdfonts.h", "gdfontmb.h","gdfontl.h" and "gdfontg.h" respectivelyand (if you are not using a library-based approach) link with the corresponding .c files to use the provided fonts.The null-terminated C string specifiedby the fifth argument is drawn from left to right in the specified color. (See <A HREF="#gdImageStringUp">gdImageStringUp</A> for a wayof drawing vertical text.) Pixels notset by a particular character retain their previous color. <PRE>#include "gd.h"#include "gdfontl.h"#include <string.h>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;/* String to draw. */char *s = "Hello.";im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0); /* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255); /* Draw a centered string. */gdImageString(im, gdFontLarge, im->w / 2 - (strlen(s) * gdFontLarge->w / 2), im->h / 2 - gdFontLarge->h / 2, s, white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageStringUp">void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, char *s, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageStringUp is used to draw multiple characters on the image,rotated 90 degrees.(To draw single characters, use <A HREF="#gdImageCharUp">gdImageCharUp</A>.) The second argument is apointer to a font definition structure; five fonts areprovided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,gdFontLarge, and gdFontGiant. You mustinclude the files "gdfontt.h", "gdfonts.h", "gdfontmb.h","gdfontl.h" and "gdfontg.h" respectivelyand (if you are not using a library-based approach) link with the corresponding .c files to use the provided fonts.The null-terminated C string specifiedby the fifth argument is drawn from bottom to top (rotated90 degrees) in the specified color. (See <A HREF="#gdImageString">gdImageString</A> for a wayof drawing horizontal text.) Pixels notset by a particular character retain their previous color. <PRE>#include "gd.h"#include "gdfontl.h"#include <string.h>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;/* String to draw. */char *s = "Hello.";im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0); /* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255); /* Draw a centered string going upwards. Axes are reversed, and Y axis is decreasing as the string is drawn. */gdImageStringUp(im, gdFontLarge, im->w / 2 - gdFontLarge->h / 2, im->h / 2 + (strlen(s) * gdFontLarge->w / 2), s, white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE></DL><H3><A NAME="colors">Color-handling functions</A></H3><DL><DT><A NAME="gdImageColorAllocate">int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageColorAllocate finds the first available color index inthe image specified, sets its RGB values to those requested(255 is the maximum for each),and returns the index of the new color table entry. Whencreating a new image, the first time you invoke this function,you are setting the background color for that image.<P>In the event that all <A HREF="#gdM
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?