Class Image
(Defined in: jpgraph.php : 5929)

Image

RoundedRectangle()
SetAlphaBlending()
SetAntiAliasing()
SetCanvasColor()
SetExpired()
SetImgFormat()
SetMargin()
SetQuality()
SetTransparent()

Class usage and Overview
The Image class encapsulates the very lowest layer in the jpgraph library. It encapsulates the GD library function and presents a coherent interface hiding som of the details in the setup and management of GD.

By replacing Image (and RotImage) it is possible to change the output driver for the whole library withou any further changes.

A very close related class is RotImage which builds directly on Image but in additoin provides a 2D rotation featire, i.e the image may be rotated around a given point and possible also translated.

The image gets instantiated through in the Graph::Img property, or more accurate the RotImage class gets instantiated. The only method in this class that any end user is likely to need (and use) is the SetMargin() method used to give the margins around between the end of the image and the actual plotarea.

Note that all coordinates in methods belonging to Image is given in direct screen coordinates.

See also related classes:
RotImage, RGB and TTF

Class Methods

Image ::
RoundedRectangle($xt, $yt, $xr, $yl, $r)
Draw a rectangle with rounded corners

Argument | Default | Description
--- | --- | ---
$xt |  | Top left X
$yt |  | Top left Y
$xr |  | Bottom right X
$yl |  | Bottom right Y
$r | 5 | Corner radius

Description:
Draw a rectangle with rounded corners.

Example:

$img->RoundedRectangle(0,0,100,100,10);

Image ::
SetAlphaBlending($aFlg)
Enable alpha blending of colors

Argument | Default | Description
--- | --- | ---
$aFlg | true | True/false = Enable/Disable alpha blending

Description:
Alpha blending for colors can only be used with GD 2.x and above. You specify the alpha channel by adding a '@[alpha-value]' to your normal color specification. The alpha value is specified as a fraction in the range [0, 1] and indicated how much of the background color should be visible.

Alphablending is enabled by default (when GD2 is used) but can be turned off by a call to this function with the argument false.

Example:

$graph->img->SetAlphaBlending();
...
$lineplot->SetFillColor('orange@0.5');

Image ::
SetAntiAliasing()
Specify if anti-aliasing should be used

Description:
Specify if anti-aliasing should be used. Enabling anti-aliasing will greatly improve the visual apperance of certain graphs. For example spider graphs greatly benefit from this. Note: Using anti-aliasing makes line drawing roughly 8 time slower than normal lines !! So you image will take longer to construct.
See also:

- Image::Line()

Example:

$graph->img->SetAntiAliasing();

Image ::
SetCanvasColor($aColor)
Set canvas color

Argument | Default | Description
--- | --- | ---
$aColor |  | Color

Description:
Set canvas color. The canvas color is the fill color for the frame when it is first created. This is white by defult. If you specify a frame or plot area color this background color will never be visible.

The one time it matters is when you use a drop shadow on the graph. In the small area (top right and bottom left) where there is an empty are which is covered by neither the shadow nor the graph margin this area will have the canvas color.

See also:

- Graph::SetMarginColor()
- Graph::SetColor()

Example:

$graph->SetCanvasColor('lightblue');

Image ::
SetExpired($aFlg)
Turn on/off expired header

Argument | Default | Description
--- | --- | ---
$aFlg | true | True=Return expired header.

Description:
Specify that the header returned should not only contain the image format but also the meta tags to force the browser not to cache and reload the image every time the script is called.

By default this is turned on.

Note: There is no reason as far as we can tell to turn this off.

Example:

$graph->img->SetExpired(false);

Image ::
SetImgFormat($aFormat, $aQuality)
Specify what image format to use

Argument | Default | Description
--- | --- | ---
$aFormat |  | Image format
$aQuality | 75 | No description available

Description:
Specify image format. Note depending on your installation of PHP not all formats may be supported. Supported formats are:

- "gif", GIF format. Please note that GD 1.8 and above no longer supports the GIF format.
- "png", PNG format
- "jpeg", JPEG format. The quality of the JPEG format can be specified with the SetQuality() method.

See also:

- Image::SetQuality()

Example:

$graph->img->SetImgFormat('jpeg');

Image ::
SetMargin($lm, $rm, $tm, $bm)
Specify margin for the plot area

Argument | Default | Description
--- | --- | ---
$lm |  | Left margin
$rm |  | Right margin
$tm |  | Top margin
$bm |  | Bottom margin

Description:
Specify margin for the plot area.

Example:

$graph->img->SetMargin(20,20,40,20);

Image ::
SetQuality($q)
Specify JPEG image quality

Argument | Default | Description
--- | --- | ---
$q |  | Image quality paramer (0-100)

Description:
Specify JPEG image quality. For this to have any effect the image format, as specified with SetImgFormat(), must have been set to "jpeg". The quality is specified as an integer in the range 0 (worst quality) to 100 (best quality) . By default the quality is set o 75.
See also:

- Image::SetImgFormat()

Example:

$graph->image->SetQuality(40);

Image ::
SetTransparent($color)
Specify transparent color

Argument | Default | Description
--- | --- | ---
$color |  | Color

Description:
Specify transparent color for image.

Example:

$graph->img->SetTransparent("white");