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__(BCGBarcode
barcode , BCGColorcolor ) — Construct the drawing - GetImage() — Gets the image resource
-
SetImage(Bitmap
image ) — Sets the image resource - GetBarcode() — Gets the barcode associated
-
SetBarcode(BCGBarcode
barcode ) — Sets the barcode to use - GetDpi() — Gets the DPI for supported filetype
-
SetDpi(float
dpi ) — Sets the DPI for supported filetype - GetRotationAngle() — Gets the rotation angle in degree
-
SetRotationAngle(float
degree ) — Sets the rotation angle in degree - Draw() — Draws the barcode on the image resource
-
DrawException(Exception
exception ) — Draws the exception on the image resource -
FinishAsync(ImageFormat
imageStyle , stringfileName ) — 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__(BCGBarcode
barcode , BCGColorcolor ) — 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(Bitmap
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(BCGBarcode
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(float
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(float
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
exception ) — Draws the exception on the image resourceDescriptionDraws the exception passed in on the image resource. -
FinishAsync(ImageFormat
imageStyle , stringfileName ) — 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 anything fromBCGDrawing.ImageFormat . The most common are:
-BCGDrawing.ImageFormat.Png : will draw in PNG format
-BCGDrawing.ImageFormat.Jpeg : will draw in JPG format
-BCGDrawing.ImageFormat.Gif : will draw in GIF format
-BCGDrawing.ImageFormat.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.