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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> im = gdImageCreate(64, 64);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
im = gdImageCreate(64, 64);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> im = gdImageCreateTrueColor(64, 64);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
im = gdImageCreateTrueColor(64, 64);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
|
||||
See Also:
|
||||
|
||||
|
@ -362,12 +368,15 @@ BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy)
|
|||
Nothing.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> im = gdImageCreate(10, 10);
|
||||
> // ... Use the image ...
|
||||
> // Now destroy it
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
im = gdImageCreate(10, 10);
|
||||
// ... Use the image ...
|
||||
// Now destroy it
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
|
||||
*/
|
||||
|
||||
|
@ -673,9 +682,11 @@ BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b,
|
|||
Function: gdImageColorResolve
|
||||
|
||||
gdImageColorResolve is an alternative for the code fragment
|
||||
| if ((color=gdImageColorExact(im,R,G,B)) < 0)
|
||||
| if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
|
||||
| color=gdImageColorClosest(im,R,G,B);
|
||||
(start code)
|
||||
if ((color=gdImageColorExact(im,R,G,B)) < 0)
|
||||
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
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> FILE *in;
|
||||
> gdImagePtr result, src;
|
||||
>
|
||||
> in = fopen("foo.png", "rb");
|
||||
> src = gdImageCreateFromPng(in);
|
||||
>
|
||||
> result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
|
||||
FILE *in;
|
||||
gdImagePtr result, src;
|
||||
|
||||
in = fopen("foo.png", "rb");
|
||||
src = gdImageCreateFromPng(in);
|
||||
|
||||
result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
|
||||
/* 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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> {
|
||||
> gdImagePtr im, im2, im3;
|
||||
> int black, white, trans;
|
||||
> FILE *out;
|
||||
>
|
||||
> im = gdImageCreate(100, 100); // Create the image
|
||||
> white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
|
||||
> black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||
> trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
|
||||
> gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
|
||||
>
|
||||
> out = fopen("anim.gif", "wb");// Open output file in binary mode
|
||||
> gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
|
||||
> // Write the first frame. No local color map. Delay = 1s
|
||||
> gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
|
||||
>
|
||||
> // construct the second frame
|
||||
> im2 = gdImageCreate(100, 100);
|
||||
> (void)gdImageColorAllocate(im2, 255, 255, 255); // White background
|
||||
> gdImagePaletteCopy (im2, im); // Make sure the palette is identical
|
||||
> gdImageRectangle(im2, 0, 0, 15, 15, black); // Draw something
|
||||
> // Allow animation compression with transparent pixels
|
||||
> gdImageColorTransparent (im2, trans);
|
||||
> gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
|
||||
>
|
||||
> // construct the third frame
|
||||
> im3 = gdImageCreate(100, 100);
|
||||
> (void)gdImageColorAllocate(im3, 255, 255, 255); // white background
|
||||
> gdImagePaletteCopy (im3, im); // Make sure the palette is identical
|
||||
> gdImageRectangle(im3, 0, 0, 15, 20, black); // Draw something
|
||||
> // Allow animation compression with transparent pixels
|
||||
> gdImageColorTransparent (im3, trans);
|
||||
> // Add the third frame, compressing against the second one
|
||||
> gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
|
||||
> gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
|
||||
> fclose(out); // Close file
|
||||
>
|
||||
> // Destroy images
|
||||
> gdImageDestroy(im);
|
||||
> gdImageDestroy(im2);
|
||||
> gdImageDestroy(im3);
|
||||
> }
|
||||
{
|
||||
gdImagePtr im, im2, im3;
|
||||
int black, white, trans;
|
||||
FILE *out;
|
||||
|
||||
im = gdImageCreate(100, 100); // Create the image
|
||||
white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
|
||||
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||
trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
|
||||
gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
|
||||
|
||||
out = fopen("anim.gif", "wb");// Open output file in binary mode
|
||||
gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
|
||||
// Write the first frame. No local color map. Delay = 1s
|
||||
gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
|
||||
|
||||
// construct the second frame
|
||||
im2 = gdImageCreate(100, 100);
|
||||
(void)gdImageColorAllocate(im2, 255, 255, 255); // White background
|
||||
gdImagePaletteCopy (im2, im); // Make sure the palette is identical
|
||||
gdImageRectangle(im2, 0, 0, 15, 15, black); // Draw something
|
||||
// Allow animation compression with transparent pixels
|
||||
gdImageColorTransparent (im2, trans);
|
||||
gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
|
||||
|
||||
// construct the third frame
|
||||
im3 = gdImageCreate(100, 100);
|
||||
(void)gdImageColorAllocate(im3, 255, 255, 255); // white background
|
||||
gdImagePaletteCopy (im3, im); // Make sure the palette is identical
|
||||
gdImageRectangle(im3, 0, 0, 15, 20, black); // Draw something
|
||||
// Allow animation compression with transparent pixels
|
||||
gdImageColorTransparent (im3, trans);
|
||||
// Add the third frame, compressing against the second one
|
||||
gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
|
||||
gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
|
||||
fclose(out); // Close file
|
||||
|
||||
// Destroy images
|
||||
gdImageDestroy(im);
|
||||
gdImageDestroy(im2);
|
||||
gdImageDestroy(im3);
|
||||
}
|
||||
|
||||
(end code)
|
||||
*/
|
||||
|
||||
BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM,
|
||||
|
|
|
@ -174,27 +174,29 @@ static void fatal_jpeg_error(j_common_ptr cinfo)
|
|||
Nothing.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> int black, white;
|
||||
> FILE *out;
|
||||
> // Create the image
|
||||
> im = gdImageCreate(100, 100);
|
||||
> // Allocate background
|
||||
> white = gdImageColorAllocate(im, 255, 255, 255);
|
||||
> // Allocate drawing color
|
||||
> black = gdImageColorAllocate(im, 0, 0, 0);
|
||||
> // Draw rectangle
|
||||
> gdImageRectangle(im, 0, 0, 99, 99, black);
|
||||
> // Open output file in binary mode
|
||||
> out = fopen("rect.jpg", "wb");
|
||||
> // Write JPEG using default quality
|
||||
> gdImageJpeg(im, out, -1);
|
||||
> // Close file
|
||||
> fclose(out);
|
||||
> // Destroy image
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
int black, white;
|
||||
FILE *out;
|
||||
// Create the image
|
||||
im = gdImageCreate(100, 100);
|
||||
// Allocate background
|
||||
white = gdImageColorAllocate(im, 255, 255, 255);
|
||||
// Allocate drawing color
|
||||
black = gdImageColorAllocate(im, 0, 0, 0);
|
||||
// Draw rectangle
|
||||
gdImageRectangle(im, 0, 0, 99, 99, black);
|
||||
// Open output file in binary mode
|
||||
out = fopen("rect.jpg", "wb");
|
||||
// Write JPEG using default quality
|
||||
gdImageJpeg(im, out, -1);
|
||||
// Close file
|
||||
fclose(out);
|
||||
// Destroy image
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
|
||||
BGD_DECLARE(void) gdImageJpeg(gdImagePtr im, FILE *outFile, int quality)
|
||||
|
@ -468,15 +470,17 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg(FILE *inFile)
|
|||
On error, returns NULL.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> FILE *in;
|
||||
> in = fopen("myjpeg.jpg", "rb");
|
||||
> im = gdImageCreateFromJpegEx(in, GD_TRUE);
|
||||
> fclose(in);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
FILE *in;
|
||||
in = fopen("myjpeg.jpg", "rb");
|
||||
im = gdImageCreateFromJpegEx(in, GD_TRUE);
|
||||
fclose(in);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> ... inside a function ...
|
||||
> FILE *in;
|
||||
> in = fopen("mypng.png", "rb");
|
||||
> im = gdImageCreateFromPng(in);
|
||||
> fclose(in);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
... inside a function ...
|
||||
FILE *in;
|
||||
in = fopen("mypng.png", "rb");
|
||||
im = gdImageCreateFromPng(in);
|
||||
fclose(in);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * inFile)
|
||||
{
|
||||
|
@ -585,20 +587,22 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
|
|||
Nothing.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> int black, white;
|
||||
> FILE *out;
|
||||
>
|
||||
> im = gdImageCreate(100, 100); // Create the image
|
||||
> white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
|
||||
> black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||
> gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
|
||||
> out = fopen("rect.png", "wb"); // Open output file (binary)
|
||||
> gdImagePngEx(im, out, 9); // Write PNG, max compression
|
||||
> fclose(out); // Close file
|
||||
> gdImageDestroy(im); // Destroy image
|
||||
gdImagePtr im;
|
||||
int black, white;
|
||||
FILE *out;
|
||||
|
||||
im = gdImageCreate(100, 100); // Create the image
|
||||
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
|
||||
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
||||
gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
|
||||
out = fopen("rect.png", "wb"); // Open output file (binary)
|
||||
gdImagePngEx(im, out, 9); // Write PNG, max compression
|
||||
fclose(out); // Close file
|
||||
gdImageDestroy(im); // Destroy image
|
||||
|
||||
(end code)
|
||||
*/
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> FILE *in;
|
||||
> in = fopen("mywbmp.wbmp", "rb");
|
||||
> im = gdImageCreateFromWBMP(in);
|
||||
> fclose(in);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
FILE *in;
|
||||
in = fopen("mywbmp.wbmp", "rb");
|
||||
im = gdImageCreateFromWBMP(in);
|
||||
fclose(in);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> FILE *in;
|
||||
> in = fopen("myxbm.xbm", "rb");
|
||||
> im = gdImageCreateFromXbm(in);
|
||||
> fclose(in);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
FILE *in;
|
||||
in = fopen("myxbm.xbm", "rb");
|
||||
im = gdImageCreateFromXbm(in);
|
||||
fclose(in);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
*/
|
||||
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
|
||||
gdFTStringExtra structure. As of gd 2.0.5, this structure is defined
|
||||
as follows:
|
||||
(start code)
|
||||
|
||||
> typedef struct {
|
||||
> // logical OR of gdFTEX_ values
|
||||
> int flags;
|
||||
>
|
||||
> // fine tune line spacing for '\n'
|
||||
> double linespacing;
|
||||
>
|
||||
> // Preferred character mapping
|
||||
> int charmap;
|
||||
>
|
||||
> // Rendering resolution
|
||||
> int hdpi;
|
||||
> int vdpi;
|
||||
> char *xshow;
|
||||
> char *fontpath;
|
||||
> } gdFTStringExtra, *gdFTStringExtraPtr;
|
||||
typedef struct {
|
||||
// logical OR of gdFTEX_ values
|
||||
int flags;
|
||||
|
||||
// fine tune line spacing for '\n'
|
||||
double linespacing;
|
||||
|
||||
// Preferred character mapping
|
||||
int charmap;
|
||||
|
||||
// Rendering resolution
|
||||
int hdpi;
|
||||
int vdpi;
|
||||
char *xshow;
|
||||
char *fontpath;
|
||||
} gdFTStringExtra, *gdFTStringExtraPtr;
|
||||
|
||||
(end code)
|
||||
|
||||
To output multiline text with a specific line spacing, include
|
||||
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.
|
||||
|
||||
Example:
|
||||
(start code)
|
||||
|
||||
> gdImagePtr im;
|
||||
> FILE *in;
|
||||
> in = fopen("myxpm.xpm", "rb");
|
||||
> im = gdImageCreateFromXpm(in);
|
||||
> fclose(in);
|
||||
> // ... Use the image ...
|
||||
> gdImageDestroy(im);
|
||||
gdImagePtr im;
|
||||
FILE *in;
|
||||
in = fopen("myxpm.xpm", "rb");
|
||||
im = gdImageCreateFromXpm(in);
|
||||
fclose(in);
|
||||
// ... Use the image ...
|
||||
gdImageDestroy(im);
|
||||
|
||||
(end code)
|
||||
|
||||
*/
|
||||
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
|
||||
|
|
Loading…
Reference in New Issue