public class DiffusionDither
extends java.lang.Object
implements java.awt.image.BufferedImageOp, java.awt.image.RasterOp
BufferedImageOp/RasterOp implements basic
Floyd-Steinberg error-diffusion algorithm for dithering.
The weights used are 7/16, 3/16, 5/16 and 1/16, distributed like this:
| X | 7/16 | |
| 3/16 | 5/16 | 1/16 |
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.image.IndexColorModel |
indexColorModel |
| Constructor and Description |
|---|
DiffusionDither()
Creates a
DiffusionDither, with no fixed
IndexColorModel. |
DiffusionDither(java.awt.image.IndexColorModel pICM)
Creates a
DiffusionDither, using the given
IndexColorModel for dithering into. |
| Modifier and Type | Method and Description |
|---|---|
java.awt.image.BufferedImage |
createCompatibleDestImage(java.awt.image.BufferedImage pSource,
java.awt.image.ColorModel pDestCM)
Creates a compatible
BufferedImage to dither into. |
java.awt.image.WritableRaster |
createCompatibleDestRaster(java.awt.image.Raster pSrc)
Creates a compatible
Raster to dither into. |
java.awt.image.WritableRaster |
createCompatibleDestRaster(java.awt.image.Raster pSrc,
java.awt.image.IndexColorModel pIndexColorModel)
Creates a compatible
Raster to dither into. |
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 dither operation, applying basic
Floyd-Steinberg error-diffusion to the image.
|
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.
|
void |
setAlternateScans(boolean pUse)
Sets the scan mode.
|
public DiffusionDither(java.awt.image.IndexColorModel pICM)
DiffusionDither, using the given
IndexColorModel for dithering into.pICM - an IndexColorModel.public DiffusionDither()
DiffusionDither, with no fixed
IndexColorModel. The color model will be generated for each
filtering, unless the destination image already has an
IndexColorModel.public void setAlternateScans(boolean pUse)
true.pUse - true if scan mode should be alternating left/rightpublic final java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage pSource,
java.awt.image.ColorModel pDestCM)
BufferedImage to dither into.
Only IndexColorModel allowed.createCompatibleDestImage in interface java.awt.image.BufferedImageOpBufferedImageImageFilterException - if pDestCM is not null or
an instance of IndexColorModel.public final java.awt.image.WritableRaster createCompatibleDestRaster(java.awt.image.Raster pSrc)
Raster to dither into.
Only IndexColorModel allowed.createCompatibleDestRaster in interface java.awt.image.RasterOppSrc - the source rasterWritableRasterpublic final java.awt.image.WritableRaster createCompatibleDestRaster(java.awt.image.Raster pSrc,
java.awt.image.IndexColorModel pIndexColorModel)
Raster to dither into.pSrc - the source raster.pIndexColorModel - the index color model used to create a Raster.WritableRasterpublic final java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage pSrc)
getBounds2D in interface java.awt.image.BufferedImageOppSrc - the BufferedImage to be filteredpublic final java.awt.geom.Rectangle2D getBounds2D(java.awt.image.Raster pSrc)
getBounds2D in interface java.awt.image.RasterOppSrc - the Raster to be filteredRaster.public final java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D pSrcPt,
java.awt.geom.Point2D pDstPt)
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.getPoint2D in interface java.awt.image.BufferedImageOpgetPoint2D in interface java.awt.image.RasterOppSrcPt - a Point2D that represents a point
in the source imagepDstPt - a Point2Dthat represents the location
in the destinationPoint2D in the destination that
corresponds to the specified point in the source.public final java.awt.RenderingHints getRenderingHints()
getRenderingHints in interface java.awt.image.BufferedImageOpgetRenderingHints in interface java.awt.image.RasterOpRenderingHints object associated
with this op.public final java.awt.image.BufferedImage filter(java.awt.image.BufferedImage pSource,
java.awt.image.BufferedImage pDest)
filter in interface java.awt.image.BufferedImageOppSource - the source imagepDest - the destination imagepDest was
null.public final java.awt.image.WritableRaster filter(java.awt.image.Raster pSource,
java.awt.image.WritableRaster pDest)
filter in interface java.awt.image.RasterOppSource - the source raster, assumed to be in sRGBpDest - the destination raster, may be nullpDest was
null.public final java.awt.image.WritableRaster filter(java.awt.image.Raster pSource,
java.awt.image.WritableRaster pDest,
java.awt.image.IndexColorModel pColorModel)
pSource - the source raster, assumed to be in sRGBpDest - the destination raster, may be nullpColorModel - the indexed color model to usepDest was
null.Copyright © 2018. All Rights Reserved.