BBXImage Utility Overview

Description

In BBj 9.00 and higher, the BBXImage utility provides an object-oriented way to manipulate an image in a variety of ways. Obtain the BBXImage from a BBjImage, from a file on the server, or from a URL such as an HTTP URL that retrieves an image from the Internet. You can then modify the BBXImage in a number of ways and affect its scale (as a percentage or proportional to width or height), rotation, and opacity. It is also possible to add borders, drop shadows, reflections, and even crop the corners of the image. After manipulating the BBXImage, the class offers methods to save it in a variety of image formats such as a PNG or JPG file with a configurable compression percentage.

Feature List

Enhancements added in BBj 21.12 and higher:

  • The manipulation methods have been updated to return the BBXImage. This makes it possible to chain multiple method calls, as in:
  • xImage!.scale(100, 100).rotate(90).saveAsPNG("myScaledAndRotatedeImage.png")

  • The new drawText() method allows you to draw single or multiline text on the BBXImage providing values for foreground/background color, font, alignment, and offsets

Closed Enhancements added in BBj 19.02 and higher

Provided methods to

  • Save a BBXImage to a .gif file via saveAsGIF()
  • Save a BBXImage to a .bmp file via saveAsBMP()
  • Save a BBXImage to a .tiff file via saveAsTIFF()

Closed Enhancements added in BBj 18.10 and higher

Provided methods to

Closed Enhancements added in BBj 16.20 and higher

Provided methods to

  • Get a base64-encoded ASCII string version of an image via getBase64()
  • Return the smallest image possible by cropping out the background via cropBackground()

Closed Enhancements added in BBj 15.10 and higher

  • Modify the canvas size and facilitate scaling an image while maintaining the original aspect ratio via the scaleProportionallyAndResizeCanvas() method
  • Added a new BBXImage Constructor that creates an image object by drawing text on a graphics context with customized fonts, colors, and alignment

Closed Enhancements added in BBj 15.00 and higher

The BBXImage Utility provides filtering methods to

How to use the BBXImage Utility

Here's a quick rundown of what you need to do to use it in your program:

  1. Ensure the <bbjhome>/utils/ directory is in your prefix. The BBXImage.bbj source program is located there, so if that directory is in your prefix then the utility will be accessible in your applications.
  2. Add a USE statement for the utility so that your application can reference the custom class and provide code completion for its methods. The USE statement should look like this:
    USE ::BBXImage.bbj::BBXImage

To use the BBXImage class in your application, the process goes something like this:

  1. Create a BBXImage object from something like a BBjImage, a Java Image or ImageIcon, URL, etc:
    declare BBXImage xImage!
    xImage! = new BBXImage(mySource!)
  2. Manipulate the image in some way, such as resizing the image using one of the scale methods:
    xImage!.scaleProportionally(maxWidth, maxHeight)
  3. Do something with the resultant image, like setting the contents of a BBjImageCtrl or saving it out as a compressed JPG file:
    myImageCtrl!.setImage(xImage!.getBBjImage())
    xImage!.saveAsJPG(fullPathToJpgFile$, compressionLevel75)

BBXImage Utility Errors

Error Description
313 Invalid color specified. The specified string for a hex color description was invalid. It should in a format like #fafbfc or #f0c.
400 Invalid image source provided or missing file.

See Also

BBXImage Reference Documentation

Advantage Article: Makeover Your Images With BBXImage