gd.Image
generated from ../src/mod_gd/image.cppThe image class.
Constants
Constructor
Image
Image(size,
trueColor = false)
| Name | Type | Default | Description |
|---|---|---|---|
| size | wxSize | ||
| trueColor | Boolean | false |
Creates a new Image.
Properties
| Name | Type | Description |
|---|---|---|
| clip | wxRect |
Establishes a clipping rectangle. Once clip has been set, all future
drawing operations will remain within the specified clipping area, until
a new clip is set. For instance, if a clipping rectangle of 25, 25, 75, 75
has been set within a 100x100 image, a diagonal line from 0,0 to 99,99 will
appear only between 25,25 and 75,75.
If clip is never set, the clipping area will be the entire image. |
colorsTotal ![]() |
Integer | Returns the number of colors currently allocated in a palette image. For truecolor images, the result of the property is undefined and should not be used. |
| interlace | Integer |
interlace is used to determine whether an image should be stored in a
linear fashion, in which lines will appear on the display from first to
last, or in an interlaced fashion, in which the image will "fade in" over
several passes. By default, images are not interlaced. (When writing JPEG
images, interlacing implies generating progressive JPEG files, which are
represented as a series of scans of increasing quality. Noninterlaced gd
images result in regular [sequential] JPEG data streams.)
A nonzero value for interlace turns on interlace; a zero value turns it off. Note that interlace has no effect on other functions, and has no meaning unless you save the image in PNG or JPEG format; the gd and xbm formats do not support interlace. When a PNG is loaded or a JPEG is loaded, interlace will be set according to the setting in the PNG or JPEG file. Note that many PNG and JPEG viewers and web browsers do not support interlace or the incremental display of progressive JPEGs. However, the interlaced PNG or progressive JPEG should still display; it will simply appear all at once, just as other images do. |
size ![]() |
wxSize | The size of the image |
| tile | Image | |
| transparent | Integer |
Returns the current transparent color index in the image. If there is no
transparent color, returns -1. Sets the transparent color index for the specified image to the specified index. To indicate that there should be no transparent color, use a color index of -1. Note that JPEG images do not support transparency, so this setting has no effect when writing JPEG images. The color index used should be an index allocated by colorAllocate, whether explicitly invoked by your code or implicitly invoked by loading an image. In order to ensure that your image has a reasonable appearance when viewed by users who do not have transparent background capabilities (or when you are writing a JPEG-format file, which does not support transparency), be sure to give reasonable RGB values to the color you allocate for use as a transparent color, even though it will be transparent on systems that support PNG transparency. |
trueColour ![]() |
Boolean | Returns true if the image is a truecolour image |
Methods
alphaBlending
alphaBlending(Blending)
| Name | Type | Default | Description |
|---|---|---|---|
| Blending | Integer |
The alphaBlending function allows for two different modes of drawing on truecolor images. In blending mode, which is on by default, the alpha channel component of the color supplied to all drawing functions, such as setPixel, determines how much of the underlying color should be allowed to shine through. As a result, gd automatically blends the existing color at that point with the drawing color, and stores the result in the image. The resulting pixel is opaque. In non-blending mode, the drawing color is copied literally with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images.
arc
arc(center,
size,
S,
E,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| center | wxPoint | ||
| size | wxSize | ||
| S | Integer | ||
| E | Integer | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
arc is used to draw a partial ellipse centered at the given point, with the specified width and height in pixels. The arc begins at the position in degrees specified by S and ends at the position specified by E. The arc is drawn in the color specified by the last argument. A circle can be drawn by beginning from 0 degrees and ending at 360 degrees, with width and height being equal. E must be greater than S. Values greater than 360 are interpreted modulo 360.
boundsSafe
boundsSafe(point) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| point | wxPoint |
boundsSafe returns true if the specified point is within the current clipping rectangle, false if not. The clipping rectangle is set by clip and defaults to the entire image.
colorAllocate
colorAllocate(Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour |
colorAllocate finds the first available color index in the image, sets
its RGB values to those requested,
and returns the index of the new color table entry, or an RGBA value in
the case of a truecolor image; in either case you can then use the returned
value as a parameter to drawing functions. When creating a new
palette-based image, the first time you invoke this function, you are
setting the background color for that image.
In the event that all colors (256) have already been allocated,
colorAllocate will return -1 to indicate failure.
(This is not uncommon when working with existing PNG files that already
use 256 colors.) Note that colorAllocate does not check for existing
colors that match your request; see colorExact,
colorClosest and colorClosestHWB for ways to locate
existing colors that approximate the color desired in situations where a
new color is not available. Also see colorResolve
colorAllocateAlpha
colorAllocateAlpha(Colour,
a)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour | ||
| a | Integer |
colorAllocateAlpha finds the first available color index in the image
specified, sets its RGBA values to those requested, and returns the index
of the new color table entry, or an RGBA value in the case of a truecolor
image; in either case you can then use the returned value as a parameter
to drawing functions. When creating a new palette-based image, the first
time you invoke this function, you are setting the background color for
that image.
In the event that all colors (256) have already been allocated,
colorAllocateAlpha will return -1 to indicate failure.
(This is not uncommon when working with existing PNG files that already
use 256 colors.) Note that colorAllocateAlpha does not check for existing
colors that match your request; see colorExact,
colorClosest and colorClosestHWB for ways to locate
existing colors that approximate the color desired in situations where a
new color is not available. Also see colorResolve
colorClosest
colorClosest(Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour |
colorClosest searches the colors which have been defined thus far in the
image specified and returns the index of the color with RGB values closest
to those of the request. (Closeness is determined by Euclidian distance,
which is used to determine the distance in three-dimensional color space
between colors.)
If no colors have yet been allocated in the image, colorClosest returns -1.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
This function is most useful as a backup method for choosing a drawing
color when an image already contains 256 colors and no more can be
allocated. (This is not uncommon when working with existing PNG files
that already use many colors.) See colorExact for a method of
locating exact matches only.
colorClosestAlpha
colorClosestAlpha(Colour,
a)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour | ||
| a | Integer |
colorClosestAlpha searches the colors which have been defined thus far in
the image specified and returns the index of the color with RGBA values
closest to those of the request. (Closeness is determined by Euclidian
distance, which is used to determine the distance in four-dimensional
color/alpha space between colors.)
If no colors have yet been allocated in the image, colorClosestAlpha
returns -1.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
This function is most useful as a backup method for choosing a drawing
color when a palette-based image already contains 256 colors and no more
can be allocated. (This is not uncommon when working with existing
palette-based PNG files that already use many colors.)
See colorExactAlpha for a method of locating exact matches only.
colorClosestHWB
colorClosestHWB(Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour |
colorClosestHWB searches the colors which have been defined thus far in
the image specified and returns the index of the color with hue, whiteness
and blackness closest to the requested color. This scheme is typically
superior to the Euclidian distance scheme used by colorClosest.
If no colors have yet been allocated in the image, colorClosestHWB
returns -1.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
This function is most useful as a backup method for choosing a drawing
color when a palette-based image already contains 256 colors and no more
can be allocated. (This is not uncommon when working with existing
palette-based PNG files that already use many colors.)
See colorExactAlpha for a method of locating exact matches only.
colorDeallocate
colorDeallocate(C)
| Name | Type | Default | Description |
|---|---|---|---|
| C | Integer | Color index |
colorDeallocate marks the specified color as being available for reuse. It does not attempt to determine whether the color index is still in use in the image. After a call to this function, the next call to colorAllocate for the same image will set new RGB values for that color index, changing the color of any pixels which have that index as a result. If multiple calls to colorDeallocate are made consecutively, the lowest-numbered index among them will be reused by the next colorAllocate call.
colorExact
colorExact(Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour |
colorExact searches the colors which have been defined thus far in the
image specified and returns the index of the first color with RGB values
which exactly match those of the request. If no allocated color matches
the request precisely, colorExact returns -1. See colorClosest
for a way to find the color closest to the color requested.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
colorResolve
colorResolve(Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour |
colorResolve searches the colors which have been defined thus far in the
image specified and returns the index of the first color with RGB values
which exactly match those of the request. If no allocated color matches
the request precisely, then colorResolve tries to allocate the exact color.
If there is no space left in the color table then colorResolve returns
the closest color (as in colorClosest). This function always
returns an index of a color.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
colorResolveAlpha
colorResolveAlpha(Colour,
A)
| Name | Type | Default | Description |
|---|---|---|---|
| Colour | wxColour | ||
| A | Integer |
colorResolveAlpha searches the colors which have been defined thus far in
the image specified and returns the index of the first color with RGB
values which exactly match those of the request. If no allocated color
matches the request precisely, then colorResolveAlpha tries to allocate
the exact color.
If there is no space left in the color table then colorResolveAlpha returns
the closest color (as in colorClosestAlpha). This function always
returns an index of a color.
When applied to a truecolor image, this function always succeeds in
returning the desired color.
copy
copy(Source,
DestPoint,
SourceRect)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestPoint | wxPoint | ||
| SourceRect | wxRect |
copy is used to copy a rectangular portion of one image to this image.
(For a way of stretching or shrinking the image in the process,
see copyResized)
The Source argument is the source image from which the region is copied.
The DestPoint specifies the point in the image to which the region will be
copied. The SourceRect specifies the region in the source image.
When you copy a region from one location in an image to another location
in the same image, copy will perform as expected unless the regions
overlap, in which case the result is unpredictable.
Important note on copying between images: since different images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. copy will attempt to find an identical RGB value in the destination image for each pixel in the copied portion of the source image by invoking colorExact. If such a value is not found, copy will attempt to allocate colors as needed using colorAllocate. If both of these methods fail, copy will invoke colorClosest to find the color in the destination image which most closely approximates the color of the pixel being copied.
copyMerge
copyMerge(Source,
DestPoint,
SourceRect,
Pct)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestPoint | wxPoint | ||
| SourceRect | wxRect | ||
| Pct | Integer |
copyMerge is almost identical to copy, except that it 'merges'
the two images by an amount specified in the last parameter. If the last
parameter is 100, then it will function identically to copy -
the source image replaces the pixels in this image.
If, however, the Pct parameter is less than 100, then the two images are
merged. With Pct = 0, no action is taken.
copyMergeGray
copyMergeGray(Source,
DestPoint,
SourceRect,
Pct)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestPoint | wxPoint | ||
| SourceRect | wxRect | ||
| Pct | Integer |
copyMergeGray is almost identical to copyMerge, except that when merging images it preserves the hue of the source by converting the destination pixels to grey scale before the copy operation.
copyResampled
copyResampled(Source,
DestRect,
SourceRect)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestRect | wxRect | ||
| SourceRect | wxRect |
copyResampled is used to copy a rectangular portion of one image to this
image, smoothly interpolating pixel values so that, in particular, reducing
the size of an image still retains a great deal of clarity.
The X and Y dimensions of the original region and the destination region
can vary, resulting in stretching or shrinking of the region as
appropriate. (For a simpler version of this function which does not deal
with resizing, see copy. For a version which does not interpolate
pixel values, see copyResized.)
The Source argument is the source image from which the region is copied.
The DestRect specifies the point in the image to which the region will be
copied. The SourceRect specifies the region in the source image. The width
and height of the source region can differ from the destination region,
allowing a region to be scaled during the copying process.
When you copy a region from one location in an image to another location
in the same image, copyResized will perform as expected unless the regions
overlap, in which case the result is unpredictable.
Important note on copying between images: since different images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. copy will attempt to find an identical RGB value in the destination image for each pixel in the copied portion of the source image by invoking colorExact. If such a value is not found, copy will attempt to allocate colors as needed using colorAllocate. If both of these methods fail, copy will invoke colorClosest to find the color in the destination image which most closely approximates the color of the pixel being copied.
copyResized
copyResized(Source,
DestRect,
SourceRect)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestRect | wxRect | ||
| SourceRect | wxRect |
copyResized is used to copy a rectangular portion of one image to this
image. The X and Y dimensions of the original region and the destination
region can vary, resulting in stretching or shrinking of the region as
appropriate. (For a simpler version of this function which does not deal
with resizing, see copy)
The Source argument is the source image from which the region is copied.
The DestRect specifies the point in the image to which the region will be
copied. The SourceRect specifies the region in the source image. The width
and height of the source region can differ from the destination region,
allowing a region to be scaled during the copying process.
When you copy a region from one location in an image to another location
in the same image, copyResized will perform as expected unless the regions
overlap, in which case the result is unpredictable.
Important note on copying between images: since different images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. copy will attempt to find an identical RGB value in the destination image for each pixel in the copied portion of the source image by invoking colorExact. If such a value is not found, copy will attempt to allocate colors as needed using colorAllocate. If both of these methods fail, copy will invoke colorClosest to find the color in the destination image which most closely approximates the color of the pixel being copied.
copyRotated
copyRotated(Source,
DestX,
DestY,
SourceRect,
Angle)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image | ||
| DestX | Double | ||
| DestY | Double | ||
| SourceRect | wxRect | ||
| Angle | Integer |
copyRotated is used to copy a rectangular portion of one image to this
image, or to another region of the same image. The SourceRect
specifies the source area. The DestX and dstY coordinates specify the
CENTER of the destination area. This important distinction is made because
the rotated rectangle may or may not be parallel to the X and Y axes.
The destination coordinates may be floating point, as the center of the
desired destination area may lie at the center of a pixel (0.5 pixels)
rather than its upper left corner. The angle specified is an integer number
of degrees, between 0 and 360, with 0 degrees causing no change, and
counterclockwise rotation as the angle increases.
When you copy a region from one location in an image to another location
in the same image, copyRotated will perform as expected unless the regions
overlap, in which case the result is unpredictable. If this presents a
problem, create a scratch image in which to keep intermediate results.
Important note on copying between images: since palette-based images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. If the destination image is not a truecolor image, colorResolveAlpha is used to choose the destination pixel.
fill
fill(wxPoint,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| wxPoint | wxPoint | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
fill floods a portion of the image with the specified color, beginning at the specified point and flooding the surrounding region of the same color as the starting point. For a way of flooding a region defined by a specific border color rather than by its interior color, see fillToBorder.
fillToBorder
fillToBorder(Point,
BorderColorIndex,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Point | wxPoint | ||
| BorderColorIndex | Integer | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
fillToBorder floods a portion of the image with the specified color, beginning at the specified point and stopping at the specified border color. For a way of flooding an area defined by the color of the starting point, see fill. The border color cannot be a special color such as gd.Tiled; it must be a proper solid color.
filledArc
filledArc(Center,
Size,
S,
E,
ColourIndex,
Style)
| Name | Type | Default | Description |
|---|---|---|---|
| Center | wxPoint | ||
| Size | wxSize | ||
| S | Integer | ||
| E | Integer | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate | |
| Style | Integer |
filledArc is used to draw a partial ellipse centered at the given point, with the specified width and height in pixels. The arc begins at the position in degrees specified by S and ends at the position specified by E. The arc is filled in the color specified by the second to last argument. A circle can be drawn by beginning from 0 degrees and ending at 360 degrees, with width and height being equal. E must be greater than S. Values greater than 360 are interpreted modulo 360. The last argument is a bitwise OR of the following possibilities: gd.arc, gd.chord, gd.pie (synonym for gd.chord), gd.noFill, and gd.edged. gd.arc and gd.chord are mutually exclusive; gd.chord just connects the starting and ending angles with a straight line, while gd.arc produces a rounded edge. gd.pie is a synonym for gd.arc. gd.noFill indicates that the arc or chord should be outlined, not filled. gd.edged, used together with gd.noFill, indicates that the beginning and ending angles should be connected to the center; this is a good way to outline (rather than fill) a 'pie slice'.
filledEllipse
filledEllipse(Center,
Size,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Center | wxPoint | ||
| Size | wxSize | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
filledEllipse is used to draw an ellipse centered at the given point, with the specified width and height in pixels. The ellipse is filled in the color specified by the last argument.
filledPolygon
filledPolygon(Points,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Points | wxPoint Array | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
filledPolygon is used to fill a polygon with the verticies (at least 3) specified, using the color index specified.
filledRectangle
filledRectangle(Rect,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Rect | wxRect | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
filledRectangle is used to draw a solid rectangle with the two corners (upper left first, then lower right) specified, using the color index specified.
getPixel
getPixel(point) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| point | wxPoint |
getPixel retrieves the color index of a particular pixel.
green
green(C)
| Name | Type | Default | Description |
|---|---|---|---|
| C | Integer |
Returns the green portion of the specified color in the image.
line
line(From,
To,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| From | wxPoint | ||
| To | wxPoint | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
line is used to draw a line between two endpoints (X1,Y1 and X2, Y2). The line is drawn using the color index specified. Note that the color index can be an actual color returned by colorAllocate or one of gd.Styled, gd.Brushed or gd.StyledBrushed.
openPolygon
openPolygon(Points,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Points | wxPoint Array | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
openPolygon is used to draw a polygon with the verticies (at least 3) specified, using the color index specified. Unlike poligon the enpoints of the line sequence are not connected to a closed polygon
paletteCopy
paletteCopy(Source)
| Name | Type | Default | Description |
|---|---|---|---|
| Source | Image |
Copies a palette from one image to this image, attempting to match the colors in this image to the colors in the source palette.
polygon
polygon(Points,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Points | wxPoint Array | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
polygon is used to draw a polygon with the verticies (at least 3) specified, using the color index specified.
rectangle
rectangle(rect,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| rect | wxRect | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
rectangle is used to draw a rectangle using the color index specified.
red
red(C)
| Name | Type | Default | Description |
|---|---|---|---|
| C | Integer |
Returns the red portion of the specified color in the image.
red
red(C)
| Name | Type | Default | Description |
|---|---|---|---|
| C | Integer |
Returns the red portion of the specified color in the image.
saveAlpha
saveAlpha(Switch)
| Name | Type | Default | Description |
|---|---|---|---|
| Switch | Integer |
setAntiAliased
setAntiAliased(ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
"Antialiasing" is a process by which jagged edges associated with line
drawing can be reduced by blending the foreground color with an
appropriate percentage of the background, depending on how much of the
pixel in question is actually within the boundaries of the line being
drawn. All line-drawing functions, such as g.dImage#line,
openPolygon and polygon, will draw antialiased lines
if the special "color" gd.AntiAliased is used when calling them.
setAntiAliased is used to specify the actual foreground color to be used
when drawing antialiased lines.
Antialiased lines can be drawn on both truecolor and palette-based images.
However, attempts to draw antialiased lines on highly complex palette-based
backgrounds may not give satisfactory results, due to the limited number
of colors available in the palette. Antialiased line-drawing on simple
backgrounds should work well with palette-based images; otherwise create
or fetch a truecolor image instead.
setAntiAliasedDontBlend
setAntiAliasedDontBlend(ColourIndex,
DontBlend)
| Name | Type | Default | Description |
|---|---|---|---|
| ColourIndex | Integer | The index of an allocated color. See colorAllocate | |
| DontBlend | Integer |
Normally, when drawing lines with the special gd.AntiAliased "color," blending with the background to reduce jagged edges is the desired behavior. However, when it is desired that lines not be blended with one particular color when it is encountered in the background, the setAntiAliasedDontBlend function can be used to indicate the special color that the foreground should stand out more clearly against.
setBrush
setBrush(Brush)
| Name | Type | Default | Description |
|---|---|---|---|
| Brush | gd.Image | A "brush" is an image used to draw wide, shaped strokes in another image |
Just as a paintbrush is not a single point, a brush image need not be a
single pixel. Any gd image can be used as a brush, and by setting the
transparent color index of the brush image with colorTransparent,
a brush of any shape can be created. All line-drawing functions, such as
line, openPolygon and polygon, will use the
current brush if the special "color" gd.Brushed or gd.StyledBrushed is
used when calling them.
setBrush is used to specify the brush to be used in a particular image.
You can set any image to be the brush. If the brush image does not have
the same color map as the first image, any colors missing from the first
image will be allocated. If not enough colors can be allocated, the closest
colors already available will be used. This allows arbitrary PNGs to be
used as brush images. It also means, however, that you should not set a
brush unless you will actually use it; if you set a rapid succession of
different brush images, you can quickly fill your color map, and the
results will not be optimal.
setPixel
setPixel(Point,
ColourIndex)
| Name | Type | Default | Description |
|---|---|---|---|
| Point | wxPoint | ||
| ColourIndex | Integer | The index of an allocated color. See colorAllocate |
Sets a pixel to a particular color.
setStyle
setStyle(Style)
| Name | Type | Default | Description |
|---|---|---|---|
| Style | Integer Array | An array of integers with the desired series of color values to be repeated. You can assign the special color value gd.Transparent to indicate that the existing color should be left unchanged for that particular pixel (allowing a dashed line to be attractively drawn over an existing image). |
It is often desirable to draw dashed lines, dotted lines, and other
variations on a broken line. setStyle can be used to set any desired
series of colors, including a special color that leaves the background
intact, to be repeated during the drawing of a line.
To draw a line using the style, use the normal line function
with the special color value gd.Styled.
setThickness
setThickness(thickness)
| Name | Type | Default | Description |
|---|---|---|---|
| thickness | Integer |
setTile
setTile(Tile)
| Name | Type | Default | Description |
|---|---|---|---|
| Tile | gd.Image | A "tile" is an image used to fill an area with a repeated pattern. |
Any gd image can be used as a tile, and by setting the transparent color index of the tile image with colorTransparent, a tile that allows certain parts of the underlying area to shine through can be created. All region-filling functions, such as fill and filledPolygon, will use the current tile if the special "color" gd.Tiled is used when calling them.
sharpen
sharpen(Pct)
| Name | Type | Default | Description |
|---|---|---|---|
| Pct | Integer |
Sharpens the specified image. Pct is a sharpening percentage, and can be greater than 100. Silently does nothing to non-truecolor images. Silently does nothing for Pct < 0. Transparency/alpha channel are not altered.
squareToCircle
squareToCircle(Radius)
| Name | Type | Default | Description |
|---|---|---|---|
| Radius | Integer |
The image MUST be square, but can have any size. Creates a new image of width and height radius * 2, in which the X axis of the original has been remapped to theta (angle) and the Y axis of the original has been remapped to rho (distance from center). This is known as a "polar coordinate transform." See also stringFTCircle, which uses this function internally.
string
string(Font,
Point,
Str,
Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Font | Font | ||
| Point | wxPoint | ||
| Str | String | ||
| Colour | Integer |
string is used to draw a string on the image.
stringFT
stringFT(Fg,
FontName,
PointSize,
Angle,
Point,
Text) : wxRect
| Name | Type | Default | Description |
|---|---|---|---|
| Fg | Integer | ||
| FontName | String | ||
| PointSize | Double | ||
| Angle | Double | ||
| Point | wxPoint | ||
| Text | String |
stringFT draws a string of anti-aliased characters on the image using the
FreeType library to render user-supplied TrueType fonts. We do not provide
TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to you.
The string is anti-aliased, meaning that there should be fewer "jaggies"
visible. The fontname is the full pathname to a TrueType font file, or a
font face name if the GDFONTPATH environment variable has been set.
In the absence of a full path, the font face name may be presented with or
without extension.
The string may be arbitrarily scaled (ptsize) and rotated (angle in
radians). The direction of rotation is counter-clockwise, with 0 radians
(0 degrees) at 3 o'clock and PI/2 radians (90 degrees) at 12 o'clock.
The returned wxRect is filled on return with the bounding rectangle
(the smallest rectangle that completely surrounds the rendered string and
does not intersect any pixel of the rendered string).
The points are relative to the text regardless of the angle, so
"upper left" means in the top left-hand corner seeing the text horizontally.
Call as a class method to get the bounding rectangle without rendering.
This is a relatively cheap operation if followed by a rendering of the
same string, because of the caching of the partial rendering during
bounding rectangle calculation.
The string is rendered in the color indicated by the Fg color index. Use
the negative of the desired color index to disable anti-aliasing.
stringFTCircle
stringFTCircle(Center,
Radius,
TextRadius,
FillPortion,
Font,
Points,
Top,
Bottom,
Fg) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Center | wxPoint | ||
| Radius | Double | ||
| TextRadius | Double | ||
| FillPortion | Double | ||
| Font | String | ||
| Points | Double | ||
| Top | String | ||
| Bottom | String | ||
| Fg | Index |
Draws the text strings specified by Top and Bottom on image, curved along the edge of a circle of radius Radius, with its center at Center. Top is written clockwise along the top; Bottom is written counterclockwise along the bottom. TextRadius determines the "height" of each character; if textRadius is 1/2 of Radius, characters extend halfway from the edge to the center. FillPortion varies from 0 to 1.0, with useful values from about 0.4 to 0.9, and determines how much of the 180 degrees of arc assigned to each section of text is actually occupied by text; 0.9 looks better than 1.0 which is rather crowded. Font is a freetype font; stringFT. Points is passed to the freetype engine and has an effect on hinting; although the size of the text is determined by Radius, TextRadius, and FillPortion, you should pass a point size that "hints" appropriately -- if you know the text will be large, pass a large point size such as 24.0 to get the best results. Fg can be any color, and may have an alpha component, do blending, etc.
stringUp
stringUp(Font,
Point,
Str,
Colour)
| Name | Type | Default | Description |
|---|---|---|---|
| Font | Font | ||
| Point | wxPoint | ||
| Str | String | ||
| Colour | Integer |
stringUp is used to draw multiple characters on the image, rotated 90 degrees

© 2002 - 2007 Franky Braem.