java.awt.image

Class LookupOp

Implemented Interfaces:
BufferedImageOp, RasterOp

public class LookupOp
extends Object
implements BufferedImageOp, RasterOp

LookupOp is a filter that converts each pixel using a lookup table. For filtering Rasters, the lookup table must have either one component that is applied to all bands, or one component for every band in the Rasters. For BufferedImages, the lookup table may apply to both color and alpha components. If the lookup table contains one component, or if there are the same number of components as color components in the source, the table applies to all color components. Otherwise the table applies to all components including alpha. Alpha premultiplication is ignored during the lookup filtering. After filtering, if color conversion is necessary, the conversion happens, taking alpha premultiplication into account.

Constructor Summary

LookupOp(LookupTable lookup, RenderingHints hints)
Construct a new LookupOp using the given LookupTable.

Method Summary

BufferedImage
createCompatibleDestImage(BufferedImage src, ColorModel dstCM)
Returns a new BufferedImage that can be used by this BufferedImageOp as the destination image when filtering the specified source image.
WritableRaster
createCompatibleDestRaster(Raster src)
Returns a raster that can be used by this RasterOp as the destination raster when operating on the specified source raster.
BufferedImage
filter(BufferedImage src, BufferedImage dst)
Converts the source image using the lookup table specified in the constructor.
WritableRaster
filter(Raster src, WritableRaster dest)
Filter a raster through a lookup table.
Rectangle2D
getBounds2D(BufferedImage src)
Returns the bounds of the destination image on the basis of this BufferedImageOp being applied to the specified source image.
Rectangle2D
getBounds2D(Raster src)
Returns the bounds of the destination raster on the basis of this RasterOp being applied to the specified source raster.
Point2D
getPoint2D(Point2D src, Point2D dst)
Returns the corresponding destination point for a given source point.
RenderingHints
getRenderingHints()
Returns the rendering hints for this operation.
LookupTable
getTable()
Return the LookupTable for this op.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

LookupOp

public LookupOp(LookupTable lookup,
                RenderingHints hints)
Construct a new LookupOp using the given LookupTable.
Parameters:
lookup - LookupTable to use.
hints - Rendering hints (can be null).

Method Details

createCompatibleDestImage

public BufferedImage createCompatibleDestImage(BufferedImage src,
                                               ColorModel dstCM)
Returns a new BufferedImage that can be used by this BufferedImageOp as the destination image when filtering the specified source image.
Specified by:
createCompatibleDestImage in interface BufferedImageOp
Parameters:
src - the source image.
dstCM - the color model for the destination image.
Returns:
A new image that can be used as the destination image.

createCompatibleDestRaster

public WritableRaster createCompatibleDestRaster(Raster src)
Returns a raster that can be used by this RasterOp as the destination raster when operating on the specified source raster.
Specified by:
createCompatibleDestRaster in interface RasterOp
Parameters:
src - the source raster.
Returns:
A new writable raster that can be used as the destination raster.

filter

public final BufferedImage filter(BufferedImage src,
                                  BufferedImage dst)
Converts the source image using the lookup table specified in the constructor. The resulting image is stored in the destination image if one is provided; otherwise a new BufferedImage is created and returned. The source image cannot use an IndexColorModel, and the destination image (if one is provided) must have the same size.
Specified by:
filter in interface BufferedImageOp
Parameters:
src - The source image.
dst - The destination image.
Returns:
The convolved image.
Throws:
IllegalArgumentException - if the rasters and/or color spaces are incompatible.
ArrayIndexOutOfBoundsException - if a pixel in the source is not contained in the LookupTable.

filter

public final WritableRaster filter(Raster src,
                                   WritableRaster dest)
Filter a raster through a lookup table. Applies the lookup table for this Rasterop to each pixel of src and puts the results in dest. If dest is null, a new Raster is created and returned.
Specified by:
filter in interface RasterOp
Parameters:
src - The source raster.
dest - The destination raster.
Returns:
The WritableRaster with the filtered pixels.
Throws:
IllegalArgumentException - if lookup table has more than one component but not the same as src and dest.
ArrayIndexOutOfBoundsException - if a pixel in the source is not contained in the LookupTable.

getBounds2D

public final Rectangle2D getBounds2D(BufferedImage src)
Returns the bounds of the destination image on the basis of this BufferedImageOp being applied to the specified source image.
Specified by:
getBounds2D in interface BufferedImageOp
Parameters:
src - the source image.
Returns:
The destination bounds.

getBounds2D

public final Rectangle2D getBounds2D(Raster src)
Returns the bounds of the destination raster on the basis of this RasterOp being applied to the specified source raster.
Specified by:
getBounds2D in interface RasterOp
Parameters:
src - the source raster.
Returns:
The destination bounds.

getPoint2D

public final Point2D getPoint2D(Point2D src,
                                Point2D dst)
Returns the corresponding destination point for a given source point. This Op will return the source point unchanged.
Specified by:
getPoint2D in interface BufferedImageOp
getPoint2D in interface RasterOp
Parameters:
src - The source point.
dst - The destination point.

getRenderingHints

public final RenderingHints getRenderingHints()
Returns the rendering hints for this operation.
Specified by:
getRenderingHints in interface BufferedImageOp
getRenderingHints in interface RasterOp
Returns:
The rendering hints.

getTable

public final LookupTable getTable()
Return the LookupTable for this op.
Returns:
The lookup table.

LookupOp.java -- Filter that converts each pixel using a lookup table. Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.