The java.awt.image.BufferedImage class is the centerpiece of the 2D API's new image capabilities. As a subclass of java.awt.Image, you can pass a BufferedImage to all of the drawImage() methods in Graphics and Graphics2D. What's so great about BufferedImage? You can access the data for the image directly, a task that was awkward previously. In this section, I'll give a quick overview of all the classes that make up a BufferedImage. Then I'll talk briefly about how you can use BufferedImage directly without worrying about what's inside it. In the remainder of this chapter, I'll burrow deeper and deeper into BufferedImage.
Remember, an image is a rectangular array of colored pixels. That's all it is. As we discuss the innards of BufferedImage, it may sound a lot more complicated. It will help to keep the simple picture in your mind.
Figure 11.1 shows what's inside a BufferedImage. I'll explain the relationships between all the pieces in this section. In the rest of this chapter, I'll explain each class — ColorModel, Raster, SampleModel, and DataBuffer — in detail.
Every BufferedImage consists of a raster and a color model. The image data itself resides in the raster, while the color model knows how to interpret the data as color.
The raster contains the data that determines each pixel's ...