In BBj 14.0 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 out as a PNG, BMP, TIFF, or JPG image file with a configurable compression percentage.
- Adjust the brightness of the image
- Adjust the contrast of the image
- Blur the image
- Sharpen the image
- Convert the image to grayscale
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. The
BBXImage.bbjsource program is located there, so if that directory is in your prefix then the utility will be accessible in your applications.
- Add a
USEstatement for the utility so that your application can reference the custom class and provide code completion for its methods. The
USEstatement should look like this:
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,
declare BBXImage xImage! xImage! = new BBXImage(mySource!)
- Manipulate the image in some way, such as resizing the image using
one of the scale methods:
- 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)
For complete BBXImage documentation, click here.