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

Code Example


// To get an example on how to use this class, check barcode classes.

Method explanations

  • __constructor__(barcode, color) — Construct the drawing
    Description
    Creates the class. The first argument must be the barcode of type BCGBarcode.
    The second argument is the background color of the drawing. This must be a BCGColor object.
    These two arguments are optional.
  • getImage() — Gets the image resource
    Description
    Gets the image resource to make other operations.
    Returns
    resource - PHP image
  • setImage(image) — Sets the image resource
    Description
    Sets 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 the getDimension() method.
  • getBarcode() — Gets the barcode associated
    Description
    Gets the barcode associated.
    Returns
  • setBarcode(barcode) — Sets the barcode to use
    Description
    Sets the barcode. The class must be a %class.barcode% object.
  • getDpi() — Gets the DPI for supported filetype
    Description
    Gets 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 filetype
    Description
    Sets 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
    Description
    Gets the rotation angle for the image in degrees. (clockwise)
    Returns
    int - value between 0 and 360
  • setRotationAngle(degree) — Sets the rotation angle in degree
    Description
    Sets 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
    Description
    Draws 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 resource
    Description
    Draws the exception passed in on the image resource.
  • finish(imageStyle, fileName) — Finishes the drawing by saving it or displaying it
    Description
    Writes the image in the specified file or to the screen if the file is not used.
    The first argument imageStyle 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
    Description
    This 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.