10.1. The New Model
The 2D API has a simple image processing model based on the BufferedImage class. Image processing operations are represented by the java.awt.image.BufferedImageOp interface. Classes that implement this interface know how to process an existing BufferedImage, called the source image, to produce a new image, the destination image. It's very easy. Figure 10.1 shows a schematic representation of this model.
Once you have a BufferedImage to use as the source, processing the image is simple. You just instantiate your favorite BufferedImageOp implementation and call its filter() method with the source image. This method returns the destination image to you as another BufferedImage:
public BufferedImage filter(BufferedImage src, BufferedImage dst)
This method processes the source image, src, using some image operation. If dst is not null, it will contain the processed image when this method returns. If dst is null, a new BufferedImage will be created containing the processed image. In either case, the processed image is returned.
Figure 10.1. Image processing the 2D way

In some cases, the source and destination image can be the same. This means that the operator processes a source image, placing the results back into the same image. At the end of the operation, the source image has become the destination image. This is called in place processing. Not all image ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access