Chapter 21. Working with Images and Other Media
Until this point, we’ve confined ourselves to working with the
high-level drawing commands of the Graphics2D class, using images in a hands-off
mode. In this section, we’ll clear up some of the mystery surrounding images
and see how they can be created and transformed. The classes in the java.awt.image package handle images and their
internals; Figure 21-1 shows the important
classes in this package.
First, we’ll return to our discussion of image loading and see how we
can get more control over image data using an ImageObserver to watch as it’s processed
asynchronously by GUI components. We’ll also see how to use the MediaTracker utility to handle the details for us.
Then, we’ll move on to the good stuff and have a look at BufferedImage, which is an image whose pixel data
is exposed to you through a memory buffer. If you’re interested in creating
sophisticated graphics, rendered images, or video, this will teach you about
the foundations of image construction in Java.
Looking in the other directions, we will also be referring
occasionally to the javax.imageio package, which is part of
the Java Advanced Imaging API (JAI). If you need even more
advanced capabilities such as image tiling, loading scaled versions of
images over the network, and deferred execution of image data processing for
working with really large images, you’ll want to look at JAI.
Figure 21-1. The java.awt.image package