BBXImage Utility Overview


Description

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.

In BBj 15.0 and higher, the BBXImage Utility provides filtering methods to

  • 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:

  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)
         
 

 For complete BBXImage documentation, click here.