Home > Articles

  • Print
  • + Share This
This chapter is from the book

A Note about Filters Performance

Image filters perform a lot of operations on images, and performance can easily degrade if you do not pay attention to a few details. Whenever you write a filter assuming the source image will be of type INT_RGB or INT_ARGB, make sure the source image is actually of that type.

Usually, compatible images (images created with GraphicsConfiguration.createCompatibleImage()), which are designed to be in the same format as the screen, are stored as integers. It is often the case that the user's display is in 32-bit format and not the older 8-, 16-, and 24-bit formats. Therefore, it is a good idea to always load your images as compatible images.

The CustomImageOp demo loads a JPEG picture, which would normally be of type 3BYTE_BGR, and turns it into a compatible image of type INT_RGB. You can look for the call to GraphicsUtilities.loadCompatibleImage() in the source code of the demo and replace it with ImageIO.read() to see the difference when moving the sliders of the user interface. As a rule of thumb, do not hesitate to use the various methods from the GraphicsUtilities class to always use compatible images.

  • + Share This
  • 🔖 Save To Your Account