com.twelvemonkeys.image
Class CopyDither

java.lang.Object
  extended by com.twelvemonkeys.image.CopyDither
All Implemented Interfaces:
BufferedImageOp, RasterOp

public class CopyDither
extends Object
implements BufferedImageOp, RasterOp

This BufferedImageOp simply copies pixels, converting to a IndexColorModel.

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
protected  IndexColorModel indexColorModel
           
 
Constructor Summary
CopyDither()
          Creates a CopyDither, with no fixed IndexColorModel.
CopyDither(IndexColorModel pICM)
          Creates a CopyDither, using the given IndexColorModel for dithering into.
 
Method Summary
 BufferedImage createCompatibleDestImage(BufferedImage pSource, ColorModel pDestCM)
          Creates a compatible BufferedImage to dither into.
 WritableRaster createCompatibleDestRaster(Raster pSrc)
          Creates a compatible Raster to dither into.
 WritableRaster createCompatibleDestRaster(Raster pSrc, IndexColorModel pIndexColorModel)
           
 BufferedImage filter(BufferedImage pSource, BufferedImage pDest)
          Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.
 WritableRaster filter(Raster pSource, WritableRaster pDest)
          Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.
 WritableRaster filter(Raster pSource, WritableRaster pDest, IndexColorModel pColorModel)
          Performs a single-input/single-output pixel copy operation.
 Rectangle2D getBounds2D(BufferedImage pSrc)
          Returns the bounding box of the filtered destination image.
 Rectangle2D getBounds2D(Raster pSrc)
          Returns the bounding box of the filtered destination Raster.
 Point2D getPoint2D(Point2D pSrcPt, Point2D pDstPt)
          Returns the location of the destination point given a point in the source.
 RenderingHints getRenderingHints()
          Returns the rendering mHints for this op.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexColorModel

protected IndexColorModel indexColorModel
Constructor Detail

CopyDither

public CopyDither(IndexColorModel pICM)
Creates a CopyDither, using the given IndexColorModel for dithering into.

Parameters:
pICM - an IndexColorModel.

CopyDither

public CopyDither()
Creates a CopyDither, with no fixed IndexColorModel. The colormodel will be generated for each filtering, unless the dest image allready has an IndexColorModel.

Method Detail

createCompatibleDestImage

public final BufferedImage createCompatibleDestImage(BufferedImage pSource,
                                                     ColorModel pDestCM)
Creates a compatible BufferedImage to dither into. Only IndexColorModel allowed.

Specified by:
createCompatibleDestImage in interface BufferedImageOp
Returns:
a compatible BufferedImage
Throws:
ImageFilterException - if pDestCM is not null or an instance of IndexColorModel.

createCompatibleDestRaster

public final WritableRaster createCompatibleDestRaster(Raster pSrc)
Creates a compatible Raster to dither into. Only IndexColorModel allowed.

Specified by:
createCompatibleDestRaster in interface RasterOp
Parameters:
pSrc -
Returns:
a WritableRaster

createCompatibleDestRaster

public final WritableRaster createCompatibleDestRaster(Raster pSrc,
                                                       IndexColorModel pIndexColorModel)

getBounds2D

public final Rectangle2D getBounds2D(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 interface BufferedImageOp
Parameters:
pSrc - the BufferedImage to be filtered
Returns:
the bounds of the filtered definition image.

getBounds2D

public final Rectangle2D getBounds2D(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 interface RasterOp
Parameters:
pSrc - the Raster to be filtered
Returns:
the bounds of the filtered definition Raster.

getPoint2D

public final Point2D getPoint2D(Point2D pSrcPt,
                                Point2D pDstPt)
Returns the location of the destination point given a point in the source. If dstPt is not null, it will be used to hold the return value. Since this is not a geometric operation, the srcPt will equal the dstPt.

Specified by:
getPoint2D in interface BufferedImageOp
Specified by:
getPoint2D in interface RasterOp
Parameters:
pSrcPt - a Point2D that represents a point in the source image
pDstPt - a Point2Dthat represents the location in the destination
Returns:
the Point2D in the destination that corresponds to the specified point in the source.

getRenderingHints

public final RenderingHints getRenderingHints()
Returns the rendering mHints for this op.

Specified by:
getRenderingHints in interface BufferedImageOp
Specified by:
getRenderingHints in interface RasterOp
Returns:
the RenderingHints object associated with this op.

filter

public final BufferedImage filter(BufferedImage pSource,
                                  BufferedImage pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.

Specified by:
filter in interface BufferedImageOp
Parameters:
pSource - the source image
pDest - the destiantion image
Returns:
the destination image, or a new image, if pDest was null.

filter

public final WritableRaster filter(Raster pSource,
                                   WritableRaster pDest)
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.

Specified by:
filter in interface RasterOp
Parameters:
pSource -
pDest -
Returns:
the destination raster, or a new raster, if pDest was null.

filter

public final WritableRaster filter(Raster pSource,
                                   WritableRaster pDest,
                                   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 was null.


Copyright © 2015. All Rights Reserved.