Whole document tree
5.4 Managing and Manipulating RastersA BufferedImage object uses a Raster to manage its rectangular array of pixel data. The Raster class defines fields for the image's coordinate system--width, height, and origin. A Raster object itself uses two objects to manage the pixel data, a DataBuffer and a SampleModel. The DataBuffer is the object that stores pixel data for the raster (as described on page 81), and the SampleModel provides the interpretation of pixel data from the DataBuffer (as described on page 81). 5.4.1 Creating a RasterIn most cases, you don't need to create a Raster directly, since one is supplied with any BufferedImage that you create in memory. However, one of the BufferedImage constructor methods allows you to create a Raster by passing in a WritableRaster. 5.4.2 Parent and Child RastersThe Raster class incorporates the concept of parent and child rasters. This can improve storage efficiency by allowing you to construct any number of buffered images from the same parent. The parent and its children all refer to the same data buffer, and each child has a specific offset and bounds to identify its image location in the buffer. A child identifies its ownership through its getParent method. 5.4.3 Operations on a RasterThe Raster class defines a number of ways to access pixels and pixel data. These are useful when you're implementing the RasterOp interface, which provides raster-level filtering and manipulation of image data, or when implementing any method that needs to perform low-level pixel manipulation. 5.4.4 The WritableRaster SubclassThe WritableRaster subclass provides methods for setting pixel data and samples. The Raster associated with a BufferedImage is actually a WritableRaster, thus providing full access to manipulate its pixel data. CONTENTS | PREV | NEXT Copyright © 1997-1999 Sun Microsystems, Inc. All Rights Reserved. |