CLASS Image
(Defined in: jpgraph.php : 4232) 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
function 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.
$img->RoundedRectangle(0,0,100,100,10);
function 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.
$graph->img->SetAlphaBlending();
...
$lineplot->SetFillColor('orange@0.5');
function 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
$graph->img->SetAntiAliasing();
function 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.
$graph->img->SetExpired(false);
function SetImgFormat($aFormat)
Specify what image format to use
| Argument | Default | Description |
$aFormat
| | Image format |
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
$graph->img->SetImgFormat('jpeg');
function 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.
$graph->img->SetMargin(20,20,40,20);
function SetTransparent($color)
Specify transparent color
| Argument | Default | Description |
$color
| | Color |
Description
Specify transparent color for image.
$graph->img->SetTransparent("white");