| java.lang.Object javax.media.jai.PlanarImage javax.media.jai.OpImage javax.media.jai.GeometricOpImage javax.media.jai.ScaleOpImage
All known Subclasses: com.sun.media.jai.mlib.MlibScaleOpImage, com.sun.media.jai.opimage.ScaleBilinearOpImage, com.sun.media.jai.opimage.ScaleBicubicOpImage, com.sun.media.jai.opimage.ScaleBilinearBinaryOpImage, com.sun.media.jai.opimage.ScaleGeneralOpImage, com.sun.media.jai.opimage.ScaleNearestBinaryOpImage, com.sun.media.jai.opimage.ScaleNearestOpImage,
ScaleOpImage | abstract public class ScaleOpImage extends GeometricOpImage (Code) | | A class extending WarpOpImage for use by further
extension classes that perform image scaling. Image scaling operations
require rectilinear backwards mapping and padding by the resampling
filter dimensions.
When applying scale factors of scaleX, scaleY to a source image
with the upper left pixel at (srcMinX, srcMinY) and width of srcWidth
and height of srcHeight, the resulting image is defined to have the
following bounds:
dstMinX = ceil(A), where A = srcMinX * scaleX - 0.5 + transX,
dstMinY = ceil(B), where B = srcMinY * scaleY - 0.5 + transY,
dstMaxX = ceil(C), where C = (srcMaxX + 1) * scaleX - 1.5 + transX
and srcMaxX = srcMinX + srcWidth - 1
dstMaxY = ceil(D), where D = (srcMaxY + 1) * scaleY - 1.5 + transY
and srcMaxY = srcMinY + srcHeight - 1
dstWidth = dstMaxX - dstMinX + 1
dstHeight = dstMaxY - dstMinY + 1
In the case where source's upper left pixel is located is (0, 0),
the formulae simplify to
dstMinX = 0
dstMinY = 0
dstWidth = ceil (srcWidth * scaleX - 0.5 + transX)
dstHeight = ceil (srcHeight * scaleY - 0.5 + transY)
In the case where the source's upper left pixel is located at (0, 0)
and the scaling factors are integers, the formulae further simplify to
dstMinX = 0
dstMinY = 0
dstWidth = ceil (srcWidth * scaleX + transX)
dstWidth = ceil (srcHeight * scaleY + transY)
When interpolations which require padding the source such as Bilinear
or Bicubic interpolation are specified, the source needs to be extended
such that it has the extra pixels needed to compute all the destination
pixels. This extension is performed via the BorderExtender
class. The type of border extension can be specified as a
RenderingHint to the JAI.create method.
If no BorderExtender is specified, the source will
not be extended. The scaled image size is still calculated
according to the formula specified above. However since there is not
enough source to compute all the destination pixels, only that
subset of the destination image's pixels which can be computed,
will be written in the destination. The rest of the destination
will be set to zeros.
It may be noted that the minX, minY, width and height hints as
specified through the JAI.KEY_IMAGE_LAYOUT hint in the
RenderingHints object are not honored, as this operator
calculates the destination image bounds itself. The other
ImageLayout hints, like tileWidth and tileHeight,
however are honored.
It should be noted that the superclass GeometricOpImage
automatically adds a value of Boolean.TRUE for the
JAI.KEY_REPLACE_INDEX_COLOR_MODEL to the given
configuration and passes it up to its superclass constructor
so that geometric operations are performed on the pixel values instead
of being performed on the indices into the color map for those
operations whose source(s) have an IndexColorModel .
This addition will take place only if a value for the
JAI.KEY_REPLACE_INDEX_COLOR_MODEL has not already been
provided by the user. Note that the configuration Map
is cloned before the new hint is added to it. Regarding the value for
the JAI.KEY_REPLACE_INDEX_COLOR_MODEL
RenderingHints , the operator itself can be smart
based on the parameters, i.e. while the default value for
the JAI.KEY_REPLACE_INDEX_COLOR_MODEL is
Boolean.TRUE for operations that extend this class,
in some cases the operator could set the default.
See Also: WarpOpImage See Also: OpImage |
Constructor Summary | |
public | ScaleOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, Interpolation interp, float scaleX, float scaleY, float transX, float transY) Constructs a ScaleOpImage from a RenderedImage
source, an optional BorderExtender , x and y scale
and translation factors, and an Interpolation
object. |
Method Summary | |
protected Rectangle | backwardMapRect(Rectangle destRect, int sourceIndex) Returns the minimum bounding box of the region of the specified
source to which a particular Rectangle of the
destination will be mapped.
Parameters: destRect - the Rectangle in destination coordinates. Parameters: sourceIndex - the index of the source image. | public Raster | computeTile(int tileX, int tileY) Computes a tile. | protected Rectangle | forwardMapRect(Rectangle sourceRect, int sourceIndex) Returns the minimum bounding box of the region of the destination
to which a particular Rectangle of the specified source
will be mapped.
Parameters: sourceRect - the Rectangle in source coordinates. Parameters: sourceIndex - the index of the source image. | public int | getBottomPadding() Returns the number of samples required below the center. | public int | getLeftPadding() Returns the number of samples required to the left of the center. | public int | getRightPadding() Returns the number of samples required to the right of the center. | public int | getTopPadding() Returns the number of samples required above the center. | public Point2D | mapDestPoint(Point2D destPt, int sourceIndex) Computes the position in the specified source that best
matches the supplied destination image position.
The implementation in this class returns the value of
pt in the following code snippet:
Point2D pt = (Point2D)destPt.clone();
pt.setLocation((destPt.getX() - transX + 0.5)/scaleX - 0.5,
(destPt.getY() - transY + 0.5)/scaleY - 0.5);
Subclasses requiring different behavior should override this
method.
Parameters: destPt - the position in destination image coordinatesto map to source image coordinates. Parameters: sourceIndex - the index of the source image. | public Point2D | mapSourcePoint(Point2D sourcePt, int sourceIndex) Computes the position in the destination that best
matches the supplied source image position.
The implementation in this class returns the value of
pt in the following code snippet:
Point2D pt = (Point2D)sourcePt.clone();
pt.setLocation(scaleX*(sourcePt.getX() + 0.5) + transX - 0.5,
scaleY*(sourcePt.getY() + 0.5) + transY - 0.5);
Subclasses requiring different behavior should override this
method.
Parameters: sourcePt - the position in source image coordinatesto map to destination image coordinates. Parameters: sourceIndex - the index of the source image. |
invScaleXRationalNuminvScaleXRationalDenom | protected long invScaleXRationalNuminvScaleXRationalDenom(Code) | | |
invScaleXRationalinvScaleYRational | protected Rational invScaleXRationalinvScaleYRational(Code) | | |
invScaleYRationalNuminvScaleYRationalDenom | protected long invScaleYRationalNuminvScaleYRationalDenom(Code) | | |
rationalTolerance | protected static float rationalTolerance(Code) | | |
scaleX | protected float scaleX(Code) | | The horizontal scale factor.
|
scaleXRationalNumscaleXRationalDenom | protected long scaleXRationalNumscaleXRationalDenom(Code) | | |
scaleXRationalscaleYRational | protected Rational scaleXRationalscaleYRational(Code) | | Rational representations
|
scaleY | protected float scaleY(Code) | | The vertical scale factor.
|
scaleYRationalNumscaleYRationalDenom | protected long scaleYRationalNumscaleYRationalDenom(Code) | | |
transX | protected float transX(Code) | | Thee horizontal translation factor
|
transXRationalNumtransXRationalDenom | protected long transXRationalNumtransXRationalDenom(Code) | | |
transXRationaltransYRational | protected Rational transXRationaltransYRational(Code) | | |
transY | protected float transY(Code) | | The vertical translation factor
|
transYRationalNumtransYRationalDenom | protected long transYRationalNumtransYRationalDenom(Code) | | |
ScaleOpImage | public ScaleOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, Interpolation interp, float scaleX, float scaleY, float transX, float transY)(Code) | | Constructs a ScaleOpImage from a RenderedImage
source, an optional BorderExtender , x and y scale
and translation factors, and an Interpolation
object. The image dimensions are determined by forward-mapping
the source bounds, and are passed to the superclass constructor
by means of the layout parameter. Other fields of
the layout are passed through unchanged. If
layout is null , a new
ImageLayout will be constructor to hold the bounds
information.
Note that the scale factors are represented internally as Rational
numbers in order to workaround inexact device specific representation
of floating point numbers. For instance the floating point number 1.2
is internally represented as 1.200001, which can throw the
calculations off during a forward/backward map.
The Rational approximation is valid upto the sixth decimal place.
Parameters: layout - an ImageLayout optionally containingthe tile grid layout, SampleModel , andColorModel , or null . Parameters: source - a RenderedImage . Parameters: configuration - Configurable attributes of the image includingconfiguration variables indexed byRenderingHints.Key s and image properties indexedby String s or CaselessStringKey s.This is simply forwarded to the superclass constructor. Parameters: cobbleSources - a boolean indicating whethercomputeRect expects contiguous sources. Parameters: extender - a BorderExtender , or null . Parameters: interp - an Interpolation object to use forresampling. Parameters: scaleX - scale factor along x axis. Parameters: scaleY - scale factor along y axis. Parameters: transX - translation factor along x axis. Parameters: transY - translation factor along y axis. throws: IllegalArgumentException - if source is null . throws: IllegalArgumentException - if combining thesource bounds with the layout parameter results in negativeoutput width or height. since: JAI 1.1 |
backwardMapRect | protected Rectangle backwardMapRect(Rectangle destRect, int sourceIndex)(Code) | | Returns the minimum bounding box of the region of the specified
source to which a particular Rectangle of the
destination will be mapped.
Parameters: destRect - the Rectangle in destination coordinates. Parameters: sourceIndex - the index of the source image. a Rectangle indicating the source bounding box,or null if the bounding box is unknown. throws: IllegalArgumentException - if sourceIndex isnegative or greater than the index of the last source. throws: IllegalArgumentException - if destRect isnull . since: JAI 1.1 |
computeTile | public Raster computeTile(int tileX, int tileY)(Code) | | Computes a tile. If source cobbling was requested at
construction time, the source tile boundaries are overlayed
onto the destination, cobbling is performed for areas that
intersect multiple source tiles, and
computeRect(Raster[], WritableRaster, Rectangle)
is called for each of the resulting regions. Otherwise,
computeRect(PlanarImage[], WritableRaster,
Rectangle) is called once to compute the entire active
area of the tile.
The image bounds may be larger than the bounds of the
source image. In this case, samples for which there are no
corresponding sources are set to zero.
The following steps are performed in order to compute the tile:
- The destination tile is backward mapped to compute the needed
source.
- This source is then split on tile boundaries to produce rectangles
that do not cross tile boundaries.
- These source rectangles are then forward mapped to produce
destination rectangles, and the computeRect method is called for
each corresponding pair of source and destination rectangles.
- For higher order interpolations, some source cobbling across tile
boundaries does occur.
Parameters: tileX - The X index of the tile. Parameters: tileY - The Y index of the tile. The tile as a Raster . |
forwardMapRect | protected Rectangle forwardMapRect(Rectangle sourceRect, int sourceIndex)(Code) | | Returns the minimum bounding box of the region of the destination
to which a particular Rectangle of the specified source
will be mapped.
Parameters: sourceRect - the Rectangle in source coordinates. Parameters: sourceIndex - the index of the source image. a Rectangle indicating the destinationbounding box, or null if the bounding boxis unknown. throws: IllegalArgumentException - if sourceIndex isnegative or greater than the index of the last source. throws: IllegalArgumentException - if sourceRect isnull . since: JAI 1.1 |
getBottomPadding | public int getBottomPadding()(Code) | | Returns the number of samples required below the center.
The bottom padding factor. |
getLeftPadding | public int getLeftPadding()(Code) | | Returns the number of samples required to the left of the center.
The left padding factor. |
getRightPadding | public int getRightPadding()(Code) | | Returns the number of samples required to the right of the center.
The right padding factor. |
getTopPadding | public int getTopPadding()(Code) | | Returns the number of samples required above the center.
The top padding factor. |
mapDestPoint | public Point2D mapDestPoint(Point2D destPt, int sourceIndex)(Code) | | Computes the position in the specified source that best
matches the supplied destination image position.
The implementation in this class returns the value of
pt in the following code snippet:
Point2D pt = (Point2D)destPt.clone();
pt.setLocation((destPt.getX() - transX + 0.5)/scaleX - 0.5,
(destPt.getY() - transY + 0.5)/scaleY - 0.5);
Subclasses requiring different behavior should override this
method.
Parameters: destPt - the position in destination image coordinatesto map to source image coordinates. Parameters: sourceIndex - the index of the source image. a Point2D of the same class asdestPt . throws: IllegalArgumentException - if destPt isnull . throws: IndexOutOfBoundsException - if sourceIndex isnon-zero. since: JAI 1.1.2 |
mapSourcePoint | public Point2D mapSourcePoint(Point2D sourcePt, int sourceIndex)(Code) | | Computes the position in the destination that best
matches the supplied source image position.
The implementation in this class returns the value of
pt in the following code snippet:
Point2D pt = (Point2D)sourcePt.clone();
pt.setLocation(scaleX*(sourcePt.getX() + 0.5) + transX - 0.5,
scaleY*(sourcePt.getY() + 0.5) + transY - 0.5);
Subclasses requiring different behavior should override this
method.
Parameters: sourcePt - the position in source image coordinatesto map to destination image coordinates. Parameters: sourceIndex - the index of the source image. a Point2D of the same class assourcePt . throws: IllegalArgumentException - if sourcePt isnull . throws: IndexOutOfBoundsException - if sourceIndex isnon-zero. since: JAI 1.1.2 |
Methods inherited from javax.media.jai.OpImage | protected void addTileToCache(int tileX, int tileY, Raster tile)(Code)(Java Doc) public void cancelTiles(TileRequest request, Point[] tileIndices)(Code)(Java Doc) static Vector checkSourceVector(Vector sources, boolean checkElements)(Code)(Java Doc) protected void computeRect(Raster[] sources, WritableRaster dest, Rectangle destRect)(Code)(Java Doc) protected void computeRect(PlanarImage[] sources, WritableRaster dest, Rectangle destRect)(Code)(Java Doc) public Raster computeTile(int tileX, int tileY)(Code)(Java Doc) public boolean computesUniqueTiles()(Code)(Java Doc) final protected WritableRaster createTile(int tileX, int tileY)(Code)(Java Doc) public synchronized void dispose()(Code)(Java Doc) public static int getExpandedNumBands(SampleModel sampleModel, ColorModel colorModel)(Code)(Java Doc) protected synchronized RasterFormatTag[] getFormatTags()(Code)(Java Doc) public int getOperationComputeType()(Code)(Java Doc) public Raster getTile(int tileX, int tileY)(Code)(Java Doc) public TileCache getTileCache()(Code)(Java Doc) public Object getTileCacheMetric()(Code)(Java Doc) public Point[] getTileDependencies(int tileX, int tileY, int sourceIndex)(Code)(Java Doc) protected Raster getTileFromCache(int tileX, int tileY)(Code)(Java Doc) public TileRecycler getTileRecycler()(Code)(Java Doc) public Raster[] getTiles(Point[] tileIndices)(Code)(Java Doc) public boolean hasExtender(int sourceIndex)(Code)(Java Doc) public Point2D mapDestPoint(Point2D destPt, int sourceIndex)(Code)(Java Doc) abstract public Rectangle mapDestRect(Rectangle destRect, int sourceIndex)(Code)(Java Doc) public Point2D mapSourcePoint(Point2D sourcePt, int sourceIndex)(Code)(Java Doc) abstract public Rectangle mapSourceRect(Rectangle sourceRect, int sourceIndex)(Code)(Java Doc) public void prefetchTiles(Point[] tileIndices)(Code)(Java Doc) public TileRequest queueTiles(Point[] tileIndices)(Code)(Java Doc) protected void recycleTile(Raster tile)(Code)(Java Doc) public void setTileCache(TileCache cache)(Code)(Java Doc) protected static Vector vectorize(RenderedImage image)(Code)(Java Doc) protected static Vector vectorize(RenderedImage image1, RenderedImage image2)(Code)(Java Doc) protected static Vector vectorize(RenderedImage image1, RenderedImage image2, RenderedImage image3)(Code)(Java Doc)
|
Methods inherited from javax.media.jai.PlanarImage | public static int XToTileX(int x, int tileGridXOffset, int tileWidth)(Code)(Java Doc) public int XToTileX(int x)(Code)(Java Doc) public static int YToTileY(int y, int tileGridYOffset, int tileHeight)(Code)(Java Doc) public int YToTileY(int y)(Code)(Java Doc) public void addPropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc) public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc) public synchronized boolean addSink(Object sink)(Code)(Java Doc) protected void addSink(PlanarImage sink)(Code)(Java Doc) protected void addSource(Object source)(Code)(Java Doc) public synchronized void addTileComputationListener(TileComputationListener listener)(Code)(Java Doc) public void cancelTiles(TileRequest request, Point[] tileIndices)(Code)(Java Doc) public WritableRaster copyData()(Code)(Java Doc) public WritableRaster copyData(WritableRaster raster)(Code)(Java Doc) public void copyExtendedData(WritableRaster dest, BorderExtender extender)(Code)(Java Doc) public static ColorModel createColorModel(SampleModel sm)(Code)(Java Doc) public PlanarImage createSnapshot()(Code)(Java Doc) final protected WritableRaster createWritableRaster(SampleModel sampleModel, Point location)(Code)(Java Doc) public synchronized void dispose()(Code)(Java Doc) protected void finalize() throws Throwable(Code)(Java Doc) public BufferedImage getAsBufferedImage(Rectangle rect, ColorModel cm)(Code)(Java Doc) public BufferedImage getAsBufferedImage()(Code)(Java Doc) public Rectangle getBounds()(Code)(Java Doc) public ColorModel getColorModel()(Code)(Java Doc) public Raster getData()(Code)(Java Doc) public Raster getData(Rectangle region)(Code)(Java Doc) public static ColorModel getDefaultColorModel(int dataType, int numBands)(Code)(Java Doc) public Raster getExtendedData(Rectangle region, BorderExtender extender)(Code)(Java Doc) public Graphics getGraphics()(Code)(Java Doc) public int getHeight()(Code)(Java Doc) public Object getImageID()(Code)(Java Doc) public int getMaxTileX()(Code)(Java Doc) public int getMaxTileY()(Code)(Java Doc) public int getMaxX()(Code)(Java Doc) public int getMaxY()(Code)(Java Doc) public int getMinTileX()(Code)(Java Doc) public int getMinTileY()(Code)(Java Doc) public int getMinX()(Code)(Java Doc) public int getMinY()(Code)(Java Doc) public int getNumBands()(Code)(Java Doc) public int getNumSources()(Code)(Java Doc) public int getNumXTiles()(Code)(Java Doc) public int getNumYTiles()(Code)(Java Doc) protected Hashtable getProperties()(Code)(Java Doc) public Object getProperty(String name)(Code)(Java Doc) public Class getPropertyClass(String name)(Code)(Java Doc) public String[] getPropertyNames()(Code)(Java Doc) public String[] getPropertyNames(String prefix)(Code)(Java Doc) public SampleModel getSampleModel()(Code)(Java Doc) public Vector getSinks()(Code)(Java Doc) public PlanarImage getSource(int index)(Code)(Java Doc) public PlanarImage getSourceImage(int index)(Code)(Java Doc) public Object getSourceObject(int index)(Code)(Java Doc) public Vector getSources()(Code)(Java Doc) public void getSplits(IntegerSequence xSplits, IntegerSequence ySplits, Rectangle rect)(Code)(Java Doc) abstract public Raster getTile(int tileX, int tileY)(Code)(Java Doc) public TileComputationListener[] getTileComputationListeners()(Code)(Java Doc) public TileFactory getTileFactory()(Code)(Java Doc) public int getTileGridXOffset()(Code)(Java Doc) public int getTileGridYOffset()(Code)(Java Doc) public int getTileHeight()(Code)(Java Doc) public Point[] getTileIndices(Rectangle region)(Code)(Java Doc) public Rectangle getTileRect(int tileX, int tileY)(Code)(Java Doc) public int getTileWidth()(Code)(Java Doc) public Raster[] getTiles(Point[] tileIndices)(Code)(Java Doc) public Raster[] getTiles()(Code)(Java Doc) public int getWidth()(Code)(Java Doc) public boolean overlapsMultipleTiles(Rectangle rect)(Code)(Java Doc) public void prefetchTiles(Point[] tileIndices)(Code)(Java Doc) public TileRequest queueTiles(Point[] tileIndices)(Code)(Java Doc) public void removeProperty(String name)(Code)(Java Doc) public void removePropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc) public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc) public synchronized boolean removeSink(Object sink)(Code)(Java Doc) protected boolean removeSink(PlanarImage sink)(Code)(Java Doc) public void removeSinks()(Code)(Java Doc) protected boolean removeSource(Object source)(Code)(Java Doc) protected void removeSources()(Code)(Java Doc) public synchronized void removeTileComputationListener(TileComputationListener listener)(Code)(Java Doc) protected void setImageLayout(ImageLayout layout)(Code)(Java Doc) protected void setProperties(Hashtable properties)(Code)(Java Doc) public void setProperty(String name, Object value)(Code)(Java Doc) protected void setSource(Object source, int index)(Code)(Java Doc) protected void setSources(List sourceList)(Code)(Java Doc) public static int tileXToX(int tx, int tileGridXOffset, int tileWidth)(Code)(Java Doc) public int tileXToX(int tx)(Code)(Java Doc) public static int tileYToY(int ty, int tileGridYOffset, int tileHeight)(Code)(Java Doc) public int tileYToY(int ty)(Code)(Java Doc) public String toString()(Code)(Java Doc) public static PlanarImage wrapRenderedImage(RenderedImage image)(Code)(Java Doc)
|
|
|