Mark up code examples with (start|end code)
This makes the code better readable in the sources, and we get syntax highlighting in the generated HTML wherever we want it (i.e. not necessarily always as with `-hl all`).master
parent
4778a8a946
commit
c1804def24
43
src/gd.c
43
src/gd.c
|
@ -162,11 +162,14 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> im = gdImageCreate(64, 64);
|
im = gdImageCreate(64, 64);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
|
|
||||||
See Also:
|
See Also:
|
||||||
|
|
||||||
|
@ -263,11 +266,14 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> im = gdImageCreateTrueColor(64, 64);
|
im = gdImageCreateTrueColor(64, 64);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
|
|
||||||
See Also:
|
See Also:
|
||||||
|
|
||||||
|
@ -362,12 +368,15 @@ BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy)
|
||||||
Nothing.
|
Nothing.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> im = gdImageCreate(10, 10);
|
im = gdImageCreate(10, 10);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> // Now destroy it
|
// Now destroy it
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -673,9 +682,11 @@ BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b,
|
||||||
Function: gdImageColorResolve
|
Function: gdImageColorResolve
|
||||||
|
|
||||||
gdImageColorResolve is an alternative for the code fragment
|
gdImageColorResolve is an alternative for the code fragment
|
||||||
| if ((color=gdImageColorExact(im,R,G,B)) < 0)
|
(start code)
|
||||||
| if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
|
if ((color=gdImageColorExact(im,R,G,B)) < 0)
|
||||||
| color=gdImageColorClosest(im,R,G,B);
|
if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
|
||||||
|
color=gdImageColorClosest(im,R,G,B);
|
||||||
|
(end code)
|
||||||
in a single function. Its advantage is that it is guaranteed to
|
in a single function. Its advantage is that it is guaranteed to
|
||||||
return a color index in one search over the color table.
|
return a color index in one search over the color table.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -838,15 +838,17 @@ applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
|
||||||
truecolor.
|
truecolor.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> gdImagePtr result, src;
|
gdImagePtr result, src;
|
||||||
>
|
|
||||||
> in = fopen("foo.png", "rb");
|
in = fopen("foo.png", "rb");
|
||||||
> src = gdImageCreateFromPng(in);
|
src = gdImageCreateFromPng(in);
|
||||||
>
|
|
||||||
> result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
|
result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: Look into turning this into a generic seperable filter
|
/* TODO: Look into turning this into a generic seperable filter
|
||||||
|
|
|
@ -540,50 +540,52 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
|
||||||
Nothing.
|
Nothing.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> {
|
{
|
||||||
> gdImagePtr im, im2, im3;
|
gdImagePtr im, im2, im3;
|
||||||
> int black, white, trans;
|
int black, white, trans;
|
||||||
> FILE *out;
|
FILE *out;
|
||||||
>
|
|
||||||
> im = gdImageCreate(100, 100); // Create the image
|
im = gdImageCreate(100, 100); // Create the image
|
||||||
> white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
|
white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
|
||||||
> black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||||
> trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
|
trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
|
||||||
> gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
|
gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
|
||||||
>
|
|
||||||
> out = fopen("anim.gif", "wb");// Open output file in binary mode
|
out = fopen("anim.gif", "wb");// Open output file in binary mode
|
||||||
> gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
|
gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
|
||||||
> // Write the first frame. No local color map. Delay = 1s
|
// Write the first frame. No local color map. Delay = 1s
|
||||||
> gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
|
gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
|
||||||
>
|
|
||||||
> // construct the second frame
|
// construct the second frame
|
||||||
> im2 = gdImageCreate(100, 100);
|
im2 = gdImageCreate(100, 100);
|
||||||
> (void)gdImageColorAllocate(im2, 255, 255, 255); // White background
|
(void)gdImageColorAllocate(im2, 255, 255, 255); // White background
|
||||||
> gdImagePaletteCopy (im2, im); // Make sure the palette is identical
|
gdImagePaletteCopy (im2, im); // Make sure the palette is identical
|
||||||
> gdImageRectangle(im2, 0, 0, 15, 15, black); // Draw something
|
gdImageRectangle(im2, 0, 0, 15, 15, black); // Draw something
|
||||||
> // Allow animation compression with transparent pixels
|
// Allow animation compression with transparent pixels
|
||||||
> gdImageColorTransparent (im2, trans);
|
gdImageColorTransparent (im2, trans);
|
||||||
> gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
|
gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
|
||||||
>
|
|
||||||
> // construct the third frame
|
// construct the third frame
|
||||||
> im3 = gdImageCreate(100, 100);
|
im3 = gdImageCreate(100, 100);
|
||||||
> (void)gdImageColorAllocate(im3, 255, 255, 255); // white background
|
(void)gdImageColorAllocate(im3, 255, 255, 255); // white background
|
||||||
> gdImagePaletteCopy (im3, im); // Make sure the palette is identical
|
gdImagePaletteCopy (im3, im); // Make sure the palette is identical
|
||||||
> gdImageRectangle(im3, 0, 0, 15, 20, black); // Draw something
|
gdImageRectangle(im3, 0, 0, 15, 20, black); // Draw something
|
||||||
> // Allow animation compression with transparent pixels
|
// Allow animation compression with transparent pixels
|
||||||
> gdImageColorTransparent (im3, trans);
|
gdImageColorTransparent (im3, trans);
|
||||||
> // Add the third frame, compressing against the second one
|
// Add the third frame, compressing against the second one
|
||||||
> gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
|
gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
|
||||||
> gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
|
gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
|
||||||
> fclose(out); // Close file
|
fclose(out); // Close file
|
||||||
>
|
|
||||||
> // Destroy images
|
// Destroy images
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
> gdImageDestroy(im2);
|
gdImageDestroy(im2);
|
||||||
> gdImageDestroy(im3);
|
gdImageDestroy(im3);
|
||||||
> }
|
}
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM,
|
BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM,
|
||||||
|
|
|
@ -174,27 +174,29 @@ static void fatal_jpeg_error(j_common_ptr cinfo)
|
||||||
Nothing.
|
Nothing.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> int black, white;
|
int black, white;
|
||||||
> FILE *out;
|
FILE *out;
|
||||||
> // Create the image
|
// Create the image
|
||||||
> im = gdImageCreate(100, 100);
|
im = gdImageCreate(100, 100);
|
||||||
> // Allocate background
|
// Allocate background
|
||||||
> white = gdImageColorAllocate(im, 255, 255, 255);
|
white = gdImageColorAllocate(im, 255, 255, 255);
|
||||||
> // Allocate drawing color
|
// Allocate drawing color
|
||||||
> black = gdImageColorAllocate(im, 0, 0, 0);
|
black = gdImageColorAllocate(im, 0, 0, 0);
|
||||||
> // Draw rectangle
|
// Draw rectangle
|
||||||
> gdImageRectangle(im, 0, 0, 99, 99, black);
|
gdImageRectangle(im, 0, 0, 99, 99, black);
|
||||||
> // Open output file in binary mode
|
// Open output file in binary mode
|
||||||
> out = fopen("rect.jpg", "wb");
|
out = fopen("rect.jpg", "wb");
|
||||||
> // Write JPEG using default quality
|
// Write JPEG using default quality
|
||||||
> gdImageJpeg(im, out, -1);
|
gdImageJpeg(im, out, -1);
|
||||||
> // Close file
|
// Close file
|
||||||
> fclose(out);
|
fclose(out);
|
||||||
> // Destroy image
|
// Destroy image
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BGD_DECLARE(void) gdImageJpeg(gdImagePtr im, FILE *outFile, int quality)
|
BGD_DECLARE(void) gdImageJpeg(gdImagePtr im, FILE *outFile, int quality)
|
||||||
|
@ -468,15 +470,17 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg(FILE *inFile)
|
||||||
On error, returns NULL.
|
On error, returns NULL.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> in = fopen("myjpeg.jpg", "rb");
|
in = fopen("myjpeg.jpg", "rb");
|
||||||
> im = gdImageCreateFromJpegEx(in, GD_TRUE);
|
im = gdImageCreateFromJpegEx(in, GD_TRUE);
|
||||||
> fclose(in);
|
fclose(in);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning)
|
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning)
|
||||||
{
|
{
|
||||||
|
|
44
src/gd_png.c
44
src/gd_png.c
|
@ -149,16 +149,18 @@ gdPngFlushData (png_structp png_ptr)
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> ... inside a function ...
|
... inside a function ...
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> in = fopen("mypng.png", "rb");
|
in = fopen("mypng.png", "rb");
|
||||||
> im = gdImageCreateFromPng(in);
|
im = gdImageCreateFromPng(in);
|
||||||
> fclose(in);
|
fclose(in);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * inFile)
|
BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * inFile)
|
||||||
{
|
{
|
||||||
|
@ -585,20 +587,22 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
|
||||||
Nothing.
|
Nothing.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> int black, white;
|
int black, white;
|
||||||
> FILE *out;
|
FILE *out;
|
||||||
>
|
|
||||||
> im = gdImageCreate(100, 100); // Create the image
|
im = gdImageCreate(100, 100); // Create the image
|
||||||
> white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
|
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
|
||||||
> black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||||
> gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
|
gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
|
||||||
> out = fopen("rect.png", "wb"); // Open output file (binary)
|
out = fopen("rect.png", "wb"); // Open output file (binary)
|
||||||
> gdImagePngEx(im, out, 9); // Write PNG, max compression
|
gdImagePngEx(im, out, 9); // Write PNG, max compression
|
||||||
> fclose(out); // Close file
|
fclose(out); // Close file
|
||||||
> gdImageDestroy(im); // Destroy image
|
gdImageDestroy(im); // Destroy image
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * outFile, int level)
|
BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * outFile, int level)
|
||||||
{
|
{
|
||||||
|
|
|
@ -206,15 +206,17 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx(gdIOCtx *infile)
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> in = fopen("mywbmp.wbmp", "rb");
|
in = fopen("mywbmp.wbmp", "rb");
|
||||||
> im = gdImageCreateFromWBMP(in);
|
im = gdImageCreateFromWBMP(in);
|
||||||
> fclose(in);
|
fclose(in);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP(FILE *inFile)
|
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP(FILE *inFile)
|
||||||
|
|
17
src/gd_xbm.c
17
src/gd_xbm.c
|
@ -49,14 +49,17 @@
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> in = fopen("myxbm.xbm", "rb");
|
in = fopen("myxbm.xbm", "rb");
|
||||||
> im = gdImageCreateFromXbm(in);
|
im = gdImageCreateFromXbm(in);
|
||||||
> fclose(in);
|
fclose(in);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
*/
|
*/
|
||||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
|
BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
|
||||||
{
|
{
|
||||||
|
|
35
src/gdft.c
35
src/gdft.c
|
@ -980,23 +980,26 @@ BGD_DECLARE(int) gdFontCacheSetup (void)
|
||||||
If the strex parameter is not null, it must point to a
|
If the strex parameter is not null, it must point to a
|
||||||
gdFTStringExtra structure. As of gd 2.0.5, this structure is defined
|
gdFTStringExtra structure. As of gd 2.0.5, this structure is defined
|
||||||
as follows:
|
as follows:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> typedef struct {
|
typedef struct {
|
||||||
> // logical OR of gdFTEX_ values
|
// logical OR of gdFTEX_ values
|
||||||
> int flags;
|
int flags;
|
||||||
>
|
|
||||||
> // fine tune line spacing for '\n'
|
// fine tune line spacing for '\n'
|
||||||
> double linespacing;
|
double linespacing;
|
||||||
>
|
|
||||||
> // Preferred character mapping
|
// Preferred character mapping
|
||||||
> int charmap;
|
int charmap;
|
||||||
>
|
|
||||||
> // Rendering resolution
|
// Rendering resolution
|
||||||
> int hdpi;
|
int hdpi;
|
||||||
> int vdpi;
|
int vdpi;
|
||||||
> char *xshow;
|
char *xshow;
|
||||||
> char *fontpath;
|
char *fontpath;
|
||||||
> } gdFTStringExtra, *gdFTStringExtraPtr;
|
} gdFTStringExtra, *gdFTStringExtraPtr;
|
||||||
|
|
||||||
|
(end code)
|
||||||
|
|
||||||
To output multiline text with a specific line spacing, include
|
To output multiline text with a specific line spacing, include
|
||||||
gdFTEX_LINESPACE in the setting of flags:
|
gdFTEX_LINESPACE in the setting of flags:
|
||||||
|
|
17
src/gdxpm.c
17
src/gdxpm.c
|
@ -60,14 +60,17 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
|
||||||
A pointer to the new image or NULL if an error occurred.
|
A pointer to the new image or NULL if an error occurred.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
(start code)
|
||||||
|
|
||||||
> gdImagePtr im;
|
gdImagePtr im;
|
||||||
> FILE *in;
|
FILE *in;
|
||||||
> in = fopen("myxpm.xpm", "rb");
|
in = fopen("myxpm.xpm", "rb");
|
||||||
> im = gdImageCreateFromXpm(in);
|
im = gdImageCreateFromXpm(in);
|
||||||
> fclose(in);
|
fclose(in);
|
||||||
> // ... Use the image ...
|
// ... Use the image ...
|
||||||
> gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
|
||||||
|
(end code)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
|
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
|
||||||
|
|
Loading…
Reference in New Issue