Class CopyDither
java.lang.Object
com.twelvemonkeys.image.CopyDither
- All Implemented Interfaces:
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 $
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates aCopyDither, with no fixedIndexColorModel.CopyDither(IndexColorModel pICM) Creates aCopyDither, using the givenIndexColorModelfor dithering into. -
Method Summary
Modifier and TypeMethodDescriptionfinal BufferedImagecreateCompatibleDestImage(BufferedImage pSource, ColorModel pDestCM) Creates a compatibleBufferedImageto dither into.final WritableRasterCreates a compatibleRasterto dither into.final WritableRastercreateCompatibleDestRaster(Raster pSrc, IndexColorModel pIndexColorModel) private IndexColorModelcreateIndexColorModel(Raster pSource) final BufferedImagefilter(BufferedImage pSource, BufferedImage pDest) Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.final WritableRasterfilter(Raster pSource, WritableRaster pDest) Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.final WritableRasterfilter(Raster pSource, WritableRaster pDest, IndexColorModel pColorModel) Performs a single-input/single-output pixel copy operation.final Rectangle2DgetBounds2D(BufferedImage pSrc) Returns the bounding box of the filtered destination image.final Rectangle2DgetBounds2D(Raster pSrc) Returns the bounding box of the filtered destination Raster.private IndexColorModelgetICM(BufferedImage pSource) private IndexColorModelfinal Point2DgetPoint2D(Point2D pSrcPt, Point2D pDstPt) Returns the location of the destination point given a point in the source.final RenderingHintsReturns the rendering mHints for this op.private static inttoIntARGB(int[] pRGB) Converts a int triplet to int ARGB.
-
Field Details
-
indexColorModel
-
-
Constructor Details
-
CopyDither
Creates aCopyDither, using the givenIndexColorModelfor 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 Details
-
createCompatibleDestImage
Creates a compatibleBufferedImageto dither into. OnlyIndexColorModelallowed.- Specified by:
createCompatibleDestImagein interfaceBufferedImageOp- Returns:
- a compatible
BufferedImage - Throws:
ImageFilterException- ifpDestCMis notnullor an instance ofIndexColorModel.
-
createCompatibleDestRaster
Creates a compatibleRasterto dither into. OnlyIndexColorModelallowed.- Specified by:
createCompatibleDestRasterin interfaceRasterOp- Parameters:
pSrc-- Returns:
- a
WritableRaster
-
createCompatibleDestRaster
public final WritableRaster createCompatibleDestRaster(Raster pSrc, IndexColorModel pIndexColorModel) -
getBounds2D
Returns the bounding box of the filtered destination image. Since this is not a geometric operation, the bounding box does not change.- Specified by:
getBounds2Din interfaceBufferedImageOp- Parameters:
pSrc- theBufferedImageto be filtered- Returns:
- the bounds of the filtered definition image.
-
getBounds2D
Returns the bounding box of the filtered destination Raster. Since this is not a geometric operation, the bounding box does not change.- Specified by:
getBounds2Din interfaceRasterOp- Parameters:
pSrc- theRasterto be filtered- Returns:
- the bounds of the filtered definition
Raster.
-
getPoint2D
Returns the location of the destination point given a point in the source. IfdstPtis notnull, it will be used to hold the return value. Since this is not a geometric operation, thesrcPtwill equal thedstPt.- Specified by:
getPoint2Din interfaceBufferedImageOp- Specified by:
getPoint2Din interfaceRasterOp- Parameters:
pSrcPt- aPoint2Dthat represents a point in the source imagepDstPt- aPoint2Dthat represents the location in the destination- Returns:
- the
Point2Din the destination that corresponds to the specified point in the source.
-
getRenderingHints
Returns the rendering mHints for this op.- Specified by:
getRenderingHintsin interfaceBufferedImageOp- Specified by:
getRenderingHintsin interfaceRasterOp- Returns:
- the
RenderingHintsobject associated with this op.
-
toIntARGB
private static int toIntARGB(int[] pRGB) Converts a int triplet to int ARGB. -
filter
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image.- Specified by:
filterin interfaceBufferedImageOp- Parameters:
pSource- the source imagepDest- the destiantion image- Returns:
- the destination image, or a new image, if
pDestwasnull.
-
filter
Performs a single-input/single-output dither operation, applying basic Floyd-Steinberg error-diffusion to the image. -
getICM
-
getICM
-
createIndexColorModel
-
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
pDestwasnull.
-