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:
- 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
xImage!.scale(100, 100).rotate(90).saveAsPNG("myScaledAndRotatedeImage.png")
Enhancements added in BBj 19.02 and higher
Enhancements added in BBj 18.10 and higher
Enhancements added in BBj 16.20 and higher
Enhancements added in BBj 15.10 and higher
Enhancements added in BBj 15.00 and higher
How to use the BBXImage Utility
Here's a quick rundown of what you need to do to use it in your program:
- Ensure the
<bbjhome>/utils/
directory is in your prefix. TheBBXImage.bbj
source program is located there, so if that directory is in your prefix then the utility will be accessible in your applications. - Add a
USE
statement for the utility so that your application can reference the custom class and provide code completion for its methods. TheUSE
statement should look like this:USE ::BBXImage.bbj::BBXImage
To use the BBXImage class in your application, the process goes something like this:
- Create a BBXImage object from something like a BBjImage, a Java Image or ImageIcon, URL, etc:
declare BBXImage xImage!
xImage! = new BBXImage(mySource!)
- Manipulate the image in some way, such as resizing the image using one of the scale methods:
xImage!.scaleProportionally(maxWidth, maxHeight)
- 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. |