Class java.awt.image.ColorConvertOp
java.lang.Object
|
+----java.awt.image.ColorConvertOp
- public class ColorConvertOp
- extends Object
- implements BufferedImageOp, RasterOp
This class performs a pixel-by-pixel color conversion of the data in
the source image. The resulting color values are scaled to the precision
of the destination image data type. Color conversion can be specified
via an array of ColorSpace objects or an array of ICC_Profile objects.
If the source is a BufferedImage with premultiplied alpha, the
color components are divided by the alpha component before color conversion.
If the destination is a BufferedImage with premultiplied alpha, the
color components are multiplied by the alpha component after conversion.
Rasters are treated as having no alpha channel, i.e. all channels are
color channels.
Note Source and Destination may be the same object.
Constructor Summary
|
ColorConvertOp()
Constructs a new ColorConvertOp which will convert
from a source color space to a destination color space.
|
ColorConvertOp(int colorspace)
Constructs a new ColorConvertOp from a color space identified by
an integer constant representing one of the specific predefined
color spaces from the ColorSpace class.
|
ColorConvertOp(ColorSpace cspace)
Constructs a new ColorConvertOp from a ColorSpace object.
|
ColorConvertOp(int srcColorspace,
int dstColorspace)
Constructs a new ColorConvertOp from two color spaces identified by
integer constants representing specific predefined
color spaces from the ColorSpace class.
|
ColorConvertOp(ColorSpace srcCspace,
ColorSpace dstCspace)
Constructs a new ColorConvertOp from two ColorSpace objects.
|
ColorConvertOp(ICC_Profile[] profiles)
Constructs a new ColorConvertOp from an array of ICC_Profiles.
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ColorConvertOp
public ColorConvertOp()
- Constructs a new ColorConvertOp which will convert
from a source color space to a destination color space.
This Op can be used only with BufferedImages, and will convert
directly from the ColorSpace of the source image to that of the
destination. The destination cannot be specified as null.
ColorConvertOp
public ColorConvertOp(int colorspace)
- Constructs a new ColorConvertOp from a color space identified by
an integer constant representing one of the specific predefined
color spaces from the ColorSpace class. This Op can be used only
with BufferedImages, and is primarily useful when the filter method
is invoked with a destination argument of null. In that case,
the color space defines the destination color space for the
destination created by the filter method. Otherwise, the color space
defines an intermediate space to which the source is converted before
being converted to the destination space.
ColorConvertOp
public ColorConvertOp(ColorSpace cspace)
- Constructs a new ColorConvertOp from a ColorSpace object. This
Op can be used only with BufferedImages, and is primarily useful
when the filter method is invoked with a destination argument of null.
In that case, the ColorSpace defines the destination color space
for the destination created by the filter method. Otherwise, the
ColorSpace defines an intermediate space to which the source is
converted before being converted to the destination space.
ColorConvertOp
public ColorConvertOp(int srcColorspace,
int dstColorspace)
- Constructs a new ColorConvertOp from two color spaces identified by
integer constants representing specific predefined
color spaces from the ColorSpace class. This Op is primarily
useful for calling the filter method on Rasters, in which case
the two color spaces define the operation to be performed on the
Rasters. In that case, the number of bands in the source Raster
must match the number of components in srcColorspace, and
the number of bands in the destination Raster must match the number
of components in dstColorspace. For BufferedImages, the two
color spaces define intermediate spaces through which the source
is converted before being converted to the destination space.
ColorConvertOp
public ColorConvertOp(ColorSpace srcCspace,
ColorSpace dstCspace)
- Constructs a new ColorConvertOp from two ColorSpace objects.
This Op is primarily useful for calling the filter method on
Rasters, in which case the two ColorSpaces define the operation
to be performed on the Rasters. In that case, the number of bands
in the source Raster must match the number of components in
srcCspace, and the number of bands in the destination Raster
must match the number of components in dstCspace. For BufferedImages,
the two ColorSpaces define intermediate spaces through which the
source is converted before being converted to the destination space.
ColorConvertOp
public ColorConvertOp(ICC_Profile[] profiles)
- Constructs a new ColorConvertOp from an array of ICC_Profiles.
The sequence of profiles may include profiles that represent color
spaces, profiles that represent effects, etc. If the whole sequence
does not represent a well-defined color conversion, an exception is
thrown.
For BufferedImages, if the ColorSpace
of the source BufferedImage does not match the requirements of the
first profile in the array,
the first conversion is to an appropriate ColorSpace.
If the requirements of the last profile in the array are not met
by the ColorSpace of the destination BufferedImage,
the last conversion is to the destination's ColorSpace.
For Rasters, the number of bands in the source Raster must match
the requirements of the first profile in the array, and the
number of bands in the destination Raster must match the requirements
of the last profile in the array. The array must have at least two
elements or calling the filter method for Rasters will throw an
IllegalArgumentException.
- Throws:
- IllegalArgumentException - when the profile sequence does not
specify a well-defined color conversion
getICC_Profiles
public ICC_Profile[] getICC_Profiles()
- Returns the array of ICC_Profiles used to construct this ColorConvertOp.
Returns null if the ColorConvertOp was constructed from an array of
ColorSpaces.
filter
public BufferedImage filter(BufferedImage src,
BufferedImage dest)
- ColorConvert the BufferedImage.
If the destination image is null,
a BufferedImage will be created with an appropriate ColorModel.
- Implements:
- filter in interface BufferedImageOp
filter
public WritableRaster filter(Raster src,
WritableRaster dest)
- ColorConvert the image data in the source Raster.
If the destination Raster is null, a new Raster will be created.
The number of bands in the source and destination Rasters must
meet the requirements explained above. The constructor used to
create this ColorConvertOp must have provided enough information
to define both source and destination color spaces. See above.
Otherwise, an exception is thrown.
- Implements:
- filter in interface BufferedImageOp
- Throws:
- IllegalArgumentException - if the number of source or
destination bands is incorrect or the source or
destination color spaces are undefined
getDestBounds
public Rectangle2D getDestBounds(BufferedImage src)
- Returns the bounding box of the destination, given this source.
Note that this will be the same as the the bounding box of the
source.
- Implements:
- getDestBounds in interface BufferedImageOp
getDestBounds
public Rectangle2D getDestBounds(Raster src)
- Returns the bounding box of the destination, given this source.
Note that this will be the same as the the bounding box of the
source.
- Implements:
- getDestBounds in interface BufferedImageOp
createCompatibleDestImage
public BufferedImage createCompatibleDestImage(BufferedImage src,
ColorModel destCM)
- Creates an empty destination image with the correct size and number of
components, given this source.
- Implements:
- createCompatibleDestImage in interface BufferedImageOp
- Parameters:
src
- Source image for the filter operation
destCM
- ColorModel of the destination. If null, an
appropriate ColorModel will be used.
createCompatibleDestRaster
public WritableRaster createCompatibleDestRaster(Raster src)
- Creates an empty destination Raster with the correct size and number of
bands, given this source.
- Implements:
- createCompatibleDestRaster in interface RasterOp
getDestPoint
public Point2D getDestPoint(Point2D srcPt,
Point2D dstPt)
- Returns the location of the destination point given a
point in the source image. If dstPt is non-null, it will
be used to hold the return value.
- Implements:
- getDestPoint in interface BufferedImageOp
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.