Manual - Drawing
Introduction
This class allows you to draw a barcode on an image resource. Of course, you can use another class to draw the barcode.
Methods
BCGDrawing's Methods
-
__constructor__(
barcode ,color ) — Construct the drawing - getImage() — Gets the image resource
-
setImage(
image ) — Sets the image resource - getBarcode() — Gets the barcode associated
-
setBarcode(
barcode ) — Sets the barcode to use - getDpi() — Gets the DPI for supported filetype
-
setDpi(
dpi ) — Sets the DPI for supported filetype - getRotationAngle() — Gets the rotation angle in degree
-
setRotationAngle(
degree ) — Sets the rotation angle in degree - draw() — Draws the barcode on the image resource
-
drawException(
exception ) — Draws the exception on the image resource -
finish(
imageStyle ,fileName ) — Finishes the drawing by saving it or displaying it - destroy() — Destroys the memory associated with the image
Code Example
// To get an example on how to use this class, check barcode classes.
Method explanations
-
__constructor__(
barcode ,color ) — Construct the drawingDescriptionCreates the class. The first argument must be the barcode of typeBCGBarcode .
The second argument is the background color of the drawing. This must be aBCGColor object.
These two arguments are optional. -
getImage()
—
Gets the image resource
DescriptionGets the image resource to make other operations.Returnsresource - PHP image
-
setImage(
image ) — Sets the image resourceDescriptionSets the image resource into the class. This image will be used instead of creating a new one. You must have the correct size of the image depending on the size returned by thegetDimension() method. -
getBarcode()
—
Gets the barcode associated
DescriptionGets the barcode associated.Returns
-
setBarcode(
barcode ) — Sets the barcode to useDescriptionSets the barcode. The class must be a %class.barcode% object. -
getDpi()
—
Gets the DPI for supported filetype
DescriptionGets the DPI specified for the image. The value can also be null. This means the image will be written without any DPI attribute.Returns
int - DPI or null -
setDpi(
dpi ) — Sets the DPI for supported filetypeDescriptionSets the DPI for the image. If you don't specify any DPI for the image, a value null will be used. Using a value NULL improves the performance when generating the image. The resulting image will be 72DPI if you don't specify any DPI.
Only PNG and JPG filetypes can support the DPI setting. -
getRotationAngle()
—
Gets the rotation angle in degree
DescriptionGets the rotation angle for the image in degrees. (clockwise)Returns
int - value between 0 and 360 -
setRotationAngle(
degree ) — Sets the rotation angle in degreeDescriptionSets the rotation angle for the image in degrees. (clockwise)
Note that your server may not support the imagerotate() function. -
draw()
—
Draws the barcode on the image resource
DescriptionDraws the barcode on the image resource. If you didn't specify any image with the
setImage() method, a new image will be created. -
drawException(
exception ) — Draws the exception on the image resourceDescriptionDraws the exception passed in on the image resource. -
finish(
imageStyle ,fileName ) — Finishes the drawing by saving it or displaying itDescriptionWrites the image in the specified file or to the screen if the file is not used.
The first argumentimageStyle can be one of the following:
-BCGDrawing.Format.Png : will draw in PNG format
-BCGDrawing.Format.Jpeg : will draw in JPG format
-BCGDrawing.Format.Gif : will draw in GIF format
-BCGDrawing.Format.Wbmp : will draw in WBMP format
The second argument is the path for the file if you want to save the image. -
destroy()
—
Destroys the memory associated with the image
DescriptionThis method is automatically called with PHP5. You have to call this method with PHP4 or the image will be destroyed at the end of the script.