All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.image.RescaleOp

java.lang.Object
    |
    +----java.awt.image.RescaleOp

public class RescaleOp
extends Object
implements BufferedImageOp, RasterOp
This class performs a pixel-by-pixel rescaling of the data in the source image by multiplying each pixel value by a scale factor and then adding an offset. The pixel values are clipped to the minimum/maximum of the destination image data type.

For Rasters, rescaling operates on channel elements. The number of sets of scaling constants may be one, in which case the same constants are applied to all channels, or it must equal the number of Source Raster channels.

For BufferedImages, rescaling operates on color and alpha components. The number of sets of scaling constants may be one, in which case the same constants are applied to all color and alpha components, or it must equal the number of Source color components, in which case no scaling of the alpha component (if present) is performed, or it must equal the number of Source color components plus alpha components, in which case all color and alpha components are scaled. Images with an IndexColorModel cannot be rescaled.

The pseudo code for the rescaling operation is as follows:

for each pixel from Source object {
    for each channel/component of the pixel {
        dstElement = (srcElement*scaleFactor) + offset
    }
}
 
Note that in-place operation is allowed (i.e. the source and destination can be the same object).


Constructor Index

 o RescaleOp(float, float)
Constructs a new RescaleOp with the desired scale factor and offset.
 o RescaleOp(float[], float[])
Constructs a new RescaleOp with the desired scale factors and offsets.

Method Index

 o createCompatibleDestImage(BufferedImage, ColorModel)
Creates an empty destination image with the correct size and number of channels.
 o createCompatibleDestRaster(Raster)
Creates an empty destination Raster with the correct size and number of channels.
 o filter(BufferedImage, BufferedImage)
Rescales the BufferedImage.
 o filter(Raster, WritableRaster)
Rescales the channel data in the Raster.
 o getDestBounds(BufferedImage)
Returns the bounding box of the rescaled destination.
 o getDestBounds(Raster)
Returns the bounding box of the rescaled destination.
 o getDestPoint(Point2D, Point2D)
Returns the location of the destination point given a point in the source image.
 o getNumFactors()
Returns the number of scaling factors used in this object.
 o getOffsets(float[])
Returns the offsets in the given array.
 o getScaleFactors(float[])
Returns the scale factors in the given array.

Constructors

 o RescaleOp
public RescaleOp(float[] scaleFactors,
                 float[] offsets)
Constructs a new RescaleOp with the desired scale factors and offsets. The length of the scaleFactor and offset arrays must meet the restrictions stated in the class comments above.

 o RescaleOp
public RescaleOp(float scaleFactor,
                 float offset)
Constructs a new RescaleOp with the desired scale factor and offset. The scaleFactor and offset will be applied to all channels/components in the source Raster/BufferedImage.

Methods

 o getScaleFactors
public final float[] getScaleFactors(float[] scaleFactors)
Returns the scale factors in the given array. The array is also returned for convenience.

 o getOffsets
public final float[] getOffsets(float[] offsets)
Returns the offsets in the given array. The array is also returned for convenience.

 o getNumFactors
public final int getNumFactors()
Returns the number of scaling factors used in this object.

 o filter
public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)
Rescales the BufferedImage. If the color model in the source image is not the same as that in the destination image, the pixels will be converted in the destination. If the destination image is null, a BufferedImage will be created with the source ColorModel. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

 o filter
public WritableRaster filter(Raster src,
                             WritableRaster dst)
Rescales the channel data in the Raster. If the destination Raster is null, a new Raster will be created. The source and destination must have the same number of channels. Otherwise, an exception is thrown. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

 o getDestBounds
public Rectangle2D getDestBounds(BufferedImage src)
Returns the bounding box of the rescaled destination. Since this is not a geometric operation, the bounding box does not change. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

 o getDestBounds
public Rectangle2D getDestBounds(Raster src)
Returns the bounding box of the rescaled destination. Since this is not a geometric operation, the bounding box does not change. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

 o createCompatibleDestImage
public BufferedImage createCompatibleDestImage(BufferedImage src,
                                               ColorModel destCM)
Creates an empty destination image with the correct size and number of channels. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

Parameters:
src - Source image for the filter operation.
destCM - ColorModel of the destination. If null, the ColorModel of the source will be used.
 o createCompatibleDestRaster
public WritableRaster createCompatibleDestRaster(Raster src)
Creates an empty destination Raster with the correct size and number of channels. Note that the number of scaling factors in this object must meet the restrictions stated in the class comments above. Otherwise, an exception is thrown.

 o getDestPoint
public Point2D getDestPoint(Point2D srcPt,
                            Point2D dstPt)
Returns the location of the destination point given a point in the source image. If dstPt is non-null, it will be used to hold the return value. Since this is not a geometric operation, the srcPt will equal the dstPt.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature