Package com.twelvemonkeys.image
Class CopyDither
- java.lang.Object
-
- com.twelvemonkeys.image.CopyDither
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
,java.awt.image.RasterOp
public class CopyDither extends java.lang.Object implements java.awt.image.BufferedImageOp, java.awt.image.RasterOp
This BufferedImageOp simply copies pixels, converting to aIndexColorModel
.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/image/CopyDither.java#1 $
- Author:
- Harald Kuhr, last modified by $Author: haku $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.image.IndexColorModel
indexColorModel
-
Constructor Summary
Constructors Constructor Description CopyDither()
Creates aCopyDither
, with no fixedIndexColorModel
.CopyDither(java.awt.image.IndexColorModel pICM)
Creates aCopyDither
, using the givenIndexColorModel
for dithering into.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
createCompatibleDestImage(java.awt.image.BufferedImage pSource, java.awt.image.ColorModel pDestCM)
Creates a compatibleBufferedImage
to dither into.java.awt.image.WritableRaster
createCompatibleDestRaster(java.awt.image.Raster pSrc)
Creates a compatibleRaster
to dither into.java.awt.image.WritableRaster
createCompatibleDestRaster(java.awt.image.Raster pSrc, java.awt.image.IndexColorModel pIndexColorModel)
java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage pSource, java.awt.image.BufferedImage pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.java.awt.image.WritableRaster
filter(java.awt.image.Raster pSource, java.awt.image.WritableRaster pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.java.awt.image.WritableRaster
filter(java.awt.image.Raster pSource, java.awt.image.WritableRaster pDest, java.awt.image.IndexColorModel pColorModel)
Performs a single-input/single-output pixel copy operation.java.awt.geom.Rectangle2D
getBounds2D(java.awt.image.BufferedImage pSrc)
Returns the bounding box of the filtered destination image.java.awt.geom.Rectangle2D
getBounds2D(java.awt.image.Raster pSrc)
Returns the bounding box of the filtered destination Raster.java.awt.geom.Point2D
getPoint2D(java.awt.geom.Point2D pSrcPt, java.awt.geom.Point2D pDstPt)
Returns the location of the destination point given a point in the source.java.awt.RenderingHints
getRenderingHints()
Returns the rendering mHints for this op.
-
-
-
Constructor Detail
-
CopyDither
public CopyDither(java.awt.image.IndexColorModel pICM)
Creates aCopyDither
, using the givenIndexColorModel
for dithering into.- Parameters:
pICM
- an IndexColorModel.
-
CopyDither
public CopyDither()
Creates aCopyDither
, with no fixedIndexColorModel
. The colormodel will be generated for each filtering, unless the dest image allready has anIndexColorModel
.
-
-
Method Detail
-
createCompatibleDestImage
public final java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage pSource, java.awt.image.ColorModel pDestCM)
Creates a compatibleBufferedImage
to dither into. OnlyIndexColorModel
allowed.- Specified by:
createCompatibleDestImage
in interfacejava.awt.image.BufferedImageOp
- Returns:
- a compatible
BufferedImage
- Throws:
ImageFilterException
- ifpDestCM
is notnull
or an instance ofIndexColorModel
.
-
createCompatibleDestRaster
public final java.awt.image.WritableRaster createCompatibleDestRaster(java.awt.image.Raster pSrc)
Creates a compatibleRaster
to dither into. OnlyIndexColorModel
allowed.- Specified by:
createCompatibleDestRaster
in interfacejava.awt.image.RasterOp
- Parameters:
pSrc
-- Returns:
- a
WritableRaster
-
createCompatibleDestRaster
public final java.awt.image.WritableRaster createCompatibleDestRaster(java.awt.image.Raster pSrc, java.awt.image.IndexColorModel pIndexColorModel)
-
getBounds2D
public final java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage pSrc)
Returns the bounding box of the filtered destination image. Since this is not a geometric operation, the bounding box does not change.- Specified by:
getBounds2D
in interfacejava.awt.image.BufferedImageOp
- Parameters:
pSrc
- theBufferedImage
to be filtered- Returns:
- the bounds of the filtered definition image.
-
getBounds2D
public final java.awt.geom.Rectangle2D getBounds2D(java.awt.image.Raster pSrc)
Returns the bounding box of the filtered destination Raster. Since this is not a geometric operation, the bounding box does not change.- Specified by:
getBounds2D
in interfacejava.awt.image.RasterOp
- Parameters:
pSrc
- theRaster
to be filtered- Returns:
- the bounds of the filtered definition
Raster
.
-
getPoint2D
public final java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D pSrcPt, java.awt.geom.Point2D pDstPt)
Returns the location of the destination point given a point in the source. IfdstPt
is notnull
, it will be used to hold the return value. Since this is not a geometric operation, thesrcPt
will equal thedstPt
.- Specified by:
getPoint2D
in interfacejava.awt.image.BufferedImageOp
- Specified by:
getPoint2D
in interfacejava.awt.image.RasterOp
- Parameters:
pSrcPt
- aPoint2D
that represents a point in the source imagepDstPt
- aPoint2D
that represents the location in the destination- Returns:
- the
Point2D
in the destination that corresponds to the specified point in the source.
-
getRenderingHints
public final java.awt.RenderingHints getRenderingHints()
Returns the rendering mHints for this op.- Specified by:
getRenderingHints
in interfacejava.awt.image.BufferedImageOp
- Specified by:
getRenderingHints
in interfacejava.awt.image.RasterOp
- Returns:
- the
RenderingHints
object associated with this op.
-
filter
public final java.awt.image.BufferedImage filter(java.awt.image.BufferedImage pSource, java.awt.image.BufferedImage pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.- Specified by:
filter
in interfacejava.awt.image.BufferedImageOp
- Parameters:
pSource
- the source imagepDest
- the destiantion image- Returns:
- the destination image, or a new image, if
pDest
wasnull
.
-
filter
public final java.awt.image.WritableRaster filter(java.awt.image.Raster pSource, java.awt.image.WritableRaster pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.- Specified by:
filter
in interfacejava.awt.image.RasterOp
- Parameters:
pSource
-pDest
-- Returns:
- the destination raster, or a new raster, if
pDest
wasnull
.
-
filter
public final java.awt.image.WritableRaster filter(java.awt.image.Raster pSource, java.awt.image.WritableRaster pDest, java.awt.image.IndexColorModel pColorModel)
Performs a single-input/single-output pixel copy operation.- Parameters:
pSource
-pDest
-pColorModel
-- Returns:
- the destination raster, or a new raster, if
pDest
wasnull
.
-
-