7.11.1. Constructing Raster Images
Most of the images that you manipulate are simply read in from an image file—they were either produced by a device such as a digital camera or scanner, or constructed by a drawing program. In this section, we’ll show you a different technique for constructing an image—namely, building it up a pixel at a time.
To create an image, construct a
BufferedImage object in the usual way.
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Now, call the
getRaster method to obtain an object of type
WritableRaster. You will use this object to access and modify the pixels of the image.
WritableRaster raster = image.getRaster();
setPixel method lets you set an individual pixel. The complexity here is ...