For version 0.3.1
last update: Thu Mar 24 2011
http://www.fixedpoint.jp/gauche-gd/
A fundamental class. Its instance has a foreign pointer to GD's "gdImage". It is expected as the first argument of most of procedures whose names starting with prefix `gd-image-'.
Another fundamental class. Its instance has a foreign pointer to GD's "gdFont". You can get its instance by any of "gd-font-get-*".
Each of these is an integer corresponding to its C-alternative.
It has a string value same with its C-equivalent.
Each of these is equivalent to gdTrueColorGetAlpha, gdTrueColorGetRed, gdTrueColorGetGreen, or gdTrueColorGetBlue respectively.
This is equivalent to gdAlphaBlend.
Each of these is a constructor of <gd-image> which is equivalent to gdImageCreate, gdImageCreatePalette, or gdImageCreateTrueColor respectively. If failed these return #f.
Like C's gdImageCreateFrom* family, one of these creates a <gd-image> object from a source file in its particular image format. Unlike its C's equivalents, it treats the string-value single argument as a path of source. The file handle has been closed before successful return. In case of failure #f is returned.
The gdImageCreateFromXpm equivalent, which returns a <gd-image> object in case of success, otherwise #f.
Call gdImageDestroy() explicitly. Different from the C version it is idempotent, meaning that it can be repeated safely.
(Because of gc, it is little necessary to use this procedure.)
Each of these is equivalent to gdImageSetPixel, gdImageGetPixel, or gdImageGetTrueColorPixel respectively.
The gdImageLine alternative.
Each of these is equivalent to gdImageRectangle or gdImageFilledRectangle respectively.
As well as gdImageSetClip the former one clips a rectangle from the image for subsequent drawing. The latter returns the current clip with four integer-values.
Given the coordinates of a point, return either 1 (if it is in the current clip) or 0 (otherwise). You should use it in order to check whether the coordinates is suitable or not for arguments of another procedure, e.g. gd-image-fill.
Put a single byte character on the given image with the font provided by a gd-font-get-*. If you would like to print a string containing multibyte characters, try procedure "gd-image-string-ft" or method "string!".
Put a string consising of single byte characters, with the font provided by a gd-font-get-*. If you would like to print a string containing multibyte characters, try gd-image-string-ft.
Print a string with a FreeType font specified by the path `fontlist'. Unlike the original version, it return *four* pairs of integers which represent the coordinates of the points surrounding the bounding rectangle, and coming lower-left, lower-right, upper-right, and upper-left in that order.
It is also possible to obtain these values efficiently, i.e. without printing `str', by giving #f to `im'.
If your gosh is configured with option "--enable-multibyte=utf-8", then congratulations! and multibyte characters will be available in `str' (with an appropriate font, of course). Otherwise you had better use method "string!".
The second argument of these procedure, which expresses a sequence of points, must satisfy the following conditions:
- of type proper <list>, and
- its elements are of type <pair> and consist of integers which correspond to the coordinates of a point.
Furthermore the third one is expected to be a non-negative integer.
Each of these corresponds to gdImageColorAllocate, gdImageColorAllocateAlpha, gdImageColorClosest, gdImageColorClosestAlpha, gdImageColorClosestHWB, gdImageColorExact, gdImageColorExactAlpha, gdImageColorResolve, or gdImageColorResolveAlpha respectively.
Same as gdTrueColor or gdTrueColorAlpha resp. for each.
Similar to gdImageColorDeallocate it reduces a color in the palette.
Both convert a true color image into the palette one while the latter destructively returns into the result argument `im'. If the former fails it returns #f
The gdImageColorTransparent equivalent.
The gdImagePaletteCopy alternative.
Like gdImageFilledArc or gdImageArc respectively.
The gdImageFilledEllipse equivalent.
Each of these is equivalent to gdImageFillToBorder or gdImageFill respectively.
Note that some of these will preserve the palette of the given destination image as well as their C-equivalents.
The following functions are called respectively: gdImageSetBrush, gdImageSetTile, gdImageSetAntiAliased, gdImageSetAntiAliasedDontBlend, gdImageSetThickness, gdImageInterlace, gdImageAlphaBlending, and gdImageSaveAlpha.
Given style as a list, call gdImageSetStyle.
It returns 0 for a palette image, otherwise non-0.
Each returns the sx(`width') or sy(`height') of the image respectively.
Given a palette image it returns the number of currently allocated colors in the palette.
Each of these corresponds to gdImageRed, gdImageGreen, gdImageBlue, or gdImageAlpha respectively.
Each of these is equivalent to gdImageGetTransparent or gdImageGetInterlaced respectively.
These inherits the bounds-unsafe nature from their C-alternatives.
Return 0 If two images are same wrt displayed components, otherwise non-0.
Like gdImageSquareToCircle or gdImageSharpen respectively. The former returns #f in case of failure.
One of these procedures give you the font of size Giant, Large, MediumBold, Small, or Tiny respectively, which is for gd-image-char, gd-image-string etc. When the specified size is unavailable it return #f.
(Experimental. See graphics/gd.scm and example/*.scm if interested.)
The version of GD library. Detected at the compile time of the package.
A list of symbols which mean available features of GD.
Possible symbols in the list: fontconfig freetype gif jpeg png xpm.
You can also use feature identifiers of form 'gauche.ext.graphics.gd.*' with cond-expand.
Note that they are available after loading the module.
It is expected to keep a symbol which decides the image format taken with "read-gd-image" and/or "write" unless specified.
Call `thunk' with the parameterized "current-gd-image-format" of value `fmt'.
Read a image with or without format `fmt' (such as "gif", "jpe", "jpeg", "jpg", "png", "wbmp", "gd", and "gd2"). See also "current-gd-image-format", or #f if an error occurs.
The keywords `x', `y', `w' and `h' are only for the GD2 format and corresponding to the 2nd, 3rd, 4th and 5th argument of "gdImageCreateFromGd2PartCtx" respectively.
Put a image `im' with format `fmt' (such as "gif", "jpe", "jpeg", "jpg", "png", and "wbmp").
If the JPEG format specified, you can suggest the `quality' of the resulting image. The keyword is just ignored otherwise.
If the WBMP format specified, you can set the color index of pixels which are considered as `foreground'. The keyword is just ignored otherwise.
They are the same abbreviations of "write-as". See also "current-gd-image-format".
It provides another way to output a image. It tries to create a file of path `path' even if exists and return 0 in case of success. In the former case it choices the output image format by the extension (such as "gif", "jpe", "jpeg", "jpg", "png", "wbmp", "gd", and "gd2") of the path. Explicit `fmt' is used in the latter.
Available formats (if supported): GIF, JPEG, PNG, WBMP, GD, AND GD2.
If the GD2 format specified, you can set the options of the resulting image by the keywords `chunk-size' and `compress'. If a true value following `compress' (default), then the image will be compressed with the given `chunk-size' (or, a default one without `chunk-size'). Otherwise it will be uncompressed.
See "write-as" on the keyword `quality' for JPEG and `foreground' for WBMP.
Put a character on the given `im'. If symbol 'up follows keyword `direction', "gd-image-char-up" is called instead of "gd-image-char".
The first variant calls either "gd-image-string" or "gd-image-string-up" according to the symbol following keyword `direction'.
The usage of the second one is consistent with "gd-image-string-ft".
The third, an abbreviation of the second, treats default values of parameters if not specified with keywords. See also "current-ft-*" and "with-ft-font/fg/pt/angle".
Sometimes it is useful to fix parameters in question to print strings subsequently on an image. These are reserved for such a case and its values are referred in a call of "string!" without optional arguments or keywords.
Call `thunk' with parameterized current-ft-font, current-ft-fg, current-ft-pt, and current-ft-angle. Its return value is `thunk''s one.
Create and output a GIF Animation. In case of calling gif-anim-add without the last argument `previm', GD does not optimize the resulting frames.
Rather than a pair of gif-anim-begin and gif-anim-end, gif-anim-with is often preferable.
Call `thunk' with gif-anim-began `im' and `port'. Before returning the procedure successfully, gif-anim-end is called expectedly.
pixel-for-each calls 'proc' once for each pixel of image 'im' with arguments: x-coordinate, y-coordinate, and its pixel value obtained by 'gd-image-get-pixel'. Its return value is unspecified.
This allows you to write a filter as:
(define-method invert (im <gd-image>) (pixel-for-each im (lambda (x y pixel) (gd-image-set-pixel im x y pixel (gd-true-color (- 255 (gd-image-red im pixel)) (- 255 (gd-image-green im pixel)) (- 255 (gd-image-blue im pixel)))))))
pixel-fold calls 'proc' once for each pixel of image 'im' with 4 argumens: x-coordinate, y-coordinate, its pixel value, and the temporary seed, and returns the resulting reduction.