APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.image

public Class ReplicateScaleFilter

extends ImageFilter
Class Inheritance
Known Direct Subclasses
java.awt.image.AreaAveragingScaleFilter
Imports
java.awt.image.ImageConsumer, .ColorModel, java.util.Hashtable, java.awt.Rectangle

An ImageFilter class for scaling images using the simplest algorithm. This class extends the basic ImageFilter Class to scale an existing image and provide a source for a new image containing the resampled image. The pixels in the source image are sampled to produce pixels for an image of the specified size by replicating rows and columns of pixels to scale up or omitting rows and columns of pixels to scale down.

It is meant to be used in conjunction with a FilteredImageSource object to produce scaled versions of existing images. Due to implementation dependencies, there may be differences in pixel values of an image filtered on different platforms.

Author
Jim Graham
See Also
FilteredImageSource, ImageFilter

Field Summary

Modifier and TypeField and Description
protected int
destHeight

The target height to scale the image.

protected int
destWidth

The target width to scale the image.

protected Object
outpixbuf

A byte array initialized with a size of destWidth and used to deliver a row of pixel data to the ImageConsumer.

protected int[]
srccols

An int array containing information about a column of pixels.

protected int
srcHeight

The height of the source image.

protected int[]
srcrows

An int array containing information about a row of pixels.

protected int
srcWidth

The width of the source image.

Inherited from java.awt.image.ImageFilter:
consumer

Constructor Summary

AccessConstructor and Description
public
ReplicateScaleFilter(int
the target width to scale the image
width
,
int
the target height to scale the image
height
)

Constructs a ReplicateScaleFilter that scales the pixels from its source Image as specified by the width and height parameters.

Method Summary

Modifier and TypeMethod and Description
private void
public void
setDimensions(int w, int h)

Overrides java.awt.image.ImageFilter.setDimensions.

Implements java.awt.image.ImageConsumer.setDimensions.

Override the dimensions of the source image and pass the dimensions of the new scaled size to the ImageConsumer.

public void
setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)

Overrides java.awt.image.ImageFilter.setPixels.

Implements java.awt.image.ImageConsumer.setPixels.

Choose which rows and columns of the delivered byte pixels are needed for the destination scaled image and pass through just those rows and columns that are needed, replicated as necessary.

public void
setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)

Overrides java.awt.image.ImageFilter.setPixels.

Implements java.awt.image.ImageConsumer.setPixels.

Choose which rows and columns of the delivered int pixels are needed for the destination scaled image and pass through just those rows and columns that are needed, replicated as necessary.

public void
setProperties(Hashtable<?, ?> props)

Overrides java.awt.image.ImageFilter.setProperties.

Implements java.awt.image.ImageConsumer.setProperties.

Passes along the properties from the source object after adding a property indicating the scale applied.

Inherited from java.awt.image.ImageFilter:
clonegetFilterInstanceimageCompleteresendTopDownLeftRightsetColorModelsetHints

Field Detail

destHeightback to summary
protected int destHeight

The target height to scale the image.

destWidthback to summary
protected int destWidth

The target width to scale the image.

outpixbufback to summary
protected Object outpixbuf

A byte array initialized with a size of destWidth and used to deliver a row of pixel data to the ImageConsumer.

srccolsback to summary
protected int[] srccols

An int array containing information about a column of pixels.

srcHeightback to summary
protected int srcHeight

The height of the source image.

srcrowsback to summary
protected int[] srcrows

An int array containing information about a row of pixels.

srcWidthback to summary
protected int srcWidth

The width of the source image.

Constructor Detail

ReplicateScaleFilterback to summary
public ReplicateScaleFilter(int width, int height)

Constructs a ReplicateScaleFilter that scales the pixels from its source Image as specified by the width and height parameters.

Parameters
width:int

the target width to scale the image

height:int

the target height to scale the image

Exceptions
IllegalArgumentException:
if width equals zero or height equals zero

Method Detail

calculateMapsback to summary
private void calculateMaps()
setDimensionsback to summary
public void setDimensions(int w, int h)

Overrides java.awt.image.ImageFilter.setDimensions.

Implements java.awt.image.ImageConsumer.setDimensions.

Override the dimensions of the source image and pass the dimensions of the new scaled size to the ImageConsumer.

Note

This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

See Also
ImageConsumer
setPixelsback to summary
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)

Overrides java.awt.image.ImageFilter.setPixels.

Implements java.awt.image.ImageConsumer.setPixels.

Choose which rows and columns of the delivered byte pixels are needed for the destination scaled image and pass through just those rows and columns that are needed, replicated as necessary.

Note

This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

setPixelsback to summary
public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)

Overrides java.awt.image.ImageFilter.setPixels.

Implements java.awt.image.ImageConsumer.setPixels.

Choose which rows and columns of the delivered int pixels are needed for the destination scaled image and pass through just those rows and columns that are needed, replicated as necessary.

Note

This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

setPropertiesback to summary
public void setProperties(Hashtable<?, ?> props)

Overrides java.awt.image.ImageFilter.setProperties.

Implements java.awt.image.ImageConsumer.setProperties.

Passes along the properties from the source object after adding a property indicating the scale applied. This method invokes super.setProperties, which might result in additional properties being added.

Note

This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.