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

public Class CropImageFilter

extends ImageFilter
Class Inheritance
Imports
java.awt.image.ImageConsumer, .ColorModel, java.util.Hashtable, java.awt.Rectangle

An ImageFilter class for cropping images. This class extends the basic ImageFilter Class to extract a given rectangular region of an existing Image and provide a source for a new image containing just the extracted region. It is meant to be used in conjunction with a FilteredImageSource object to produce cropped versions of existing images.
Author
Jim Graham
See Also
FilteredImageSource, ImageFilter

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int
pack-priv int
pack-priv int
Inherited from java.awt.image.ImageFilter:
consumer

Constructor Summary

AccessConstructor and Description
public
CropImageFilter(int
the x location of the top of the rectangle to be extracted
x
,
int
the y location of the top of the rectangle to be extracted
y
,
int
the width of the rectangle to be extracted
w
,
int
the height of the rectangle to be extracted
h
)

Constructs a CropImageFilter that extracts the absolute rectangular region of pixels from its source Image as specified by the x, y, w, and h parameters.

Method Summary

Modifier and TypeMethod and Description
private int
addWithoutOverflow(int x, int w)

public void
setDimensions(int w, int h)

Overrides java.awt.image.ImageFilter.setDimensions.

Implements java.awt.image.ImageConsumer.setDimensions.

Override the source image's dimensions and pass the dimensions of the rectangular cropped region 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.

Determine whether the delivered byte pixels intersect the region to be extracted and passes through only that subset of pixels that appear in the output region.

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.

Determine if the delivered int pixels intersect the region to be extracted and pass through only that subset of pixels that appear in the output region.

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 cropped region.

Inherited from java.awt.image.ImageFilter:
clonegetFilterInstanceimageCompleteresendTopDownLeftRightsetColorModelsetHints

Field Detail

cropHback to summary
pack-priv int cropH
cropWback to summary
pack-priv int cropW
cropXback to summary
pack-priv int cropX
cropYback to summary
pack-priv int cropY

Constructor Detail

CropImageFilterback to summary
public CropImageFilter(int x, int y, int w, int h)

Constructs a CropImageFilter that extracts the absolute rectangular region of pixels from its source Image as specified by the x, y, w, and h parameters.

Parameters
x:int

the x location of the top of the rectangle to be extracted

y:int

the y location of the top of the rectangle to be extracted

w:int

the width of the rectangle to be extracted

h:int

the height of the rectangle to be extracted

Method Detail

addWithoutOverflowback to summary
private int addWithoutOverflow(int x, int w)
setDimensionsback to summary
public void setDimensions(int w, int h)

Overrides java.awt.image.ImageFilter.setDimensions.

Implements java.awt.image.ImageConsumer.setDimensions.

Override the source image's dimensions and pass the dimensions of the rectangular cropped region 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.

Determine whether the delivered byte pixels intersect the region to be extracted and passes through only that subset of pixels that appear in the output region.

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.

Determine if the delivered int pixels intersect the region to be extracted and pass through only that subset of pixels that appear in the output region.

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 cropped region. 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.