Package java.awt.image Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class CropImageFilter

Constructors , Methods

public  class  java.awt.image.CropImageFilter
    extends  java.awt.image.ImageFilter  
{
        // Constructors
    public CropImageFilter(int  x, int  y, int  w, int h);	

        // Methods
    public void setDimensions(int  w, int  h);	
    public void setPixels(int  x, int  y, int  w, int  h,	
           ColorModel  model, byte  pixels[],
                    int  off, int  scansize);
    public void setPixels(int  x, int  y, int  w, int  h,	
           ColorModel  model, int  pixels[],
                    int  off, int  scansize);
    public void setProperties(Hashtable  props);	
}

The cropped image filter is an image filter for cropping images. This class extends the basic ImageFilter class to extract a given rectangular region of an existing image and provides a source for new image containing only the extracted region.

This class is meant to be used in conjunction with a FilteredImageSource to produce cropped versions of existing images.


Constructors


CropImageFilter

public CropImageFilter(int  x, int  y, int  w, int  h) 

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

ParameterDescription
x the x location of the top of the rectangle to be extracted
y the y location of the top of the rectangle to be extracted
w the width of the rectangle to be extracted
h the height of the rectangle to be extracted


Methods


setDimensions

public void setDimensions(int  w, int  h) 

The image producer calls the setDimensions of the image consumer to tell it the width and height of the image.

The setDimensions method of CroppedImageFilter ignores its arguments. It calls the setDimensions method of its image consumer with the width and height arguments of the constructor .

ParameterDescription
width the width of the image
height the height of the image

Overrides:

setDimensions in class ImageFilter .


setPixels

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

The image producer calls the setPixels method of the image consumer one or more times to deliver the pixels of the image. For more information on this method and its arguments, see setPixels.

The setPixels method of CroppedImageFilter determines if the specified rectangle intersects its cropping region. If so, it calls the setPixels method after modifying the x, y, w, h, and offset arguments to reflect only the intersecting region.

ParameterDescription
x left coordinate of rectangle
y top coordinate of rectangle
w width of rectangle
h height of rectangle
model color model for bits
pixels array of bits
off offset for first element
scansize number of elements per row.

Overrides:

setPixels in class ImageFilter .


setPixels

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

The image producer calls the setPixels method of the image consumer one or more times to deliver the pixels of the image. For more information on this method and its arguments, see setPixels.

The setPixels method of CroppedImageFilter determines if the specified rectangle intersects its cropping region. If so, it calls the setPixels method after modifying the x, y, w, h, and offset arguments to reflect only the intersecting region.

ParameterDescription
x left coordinate of rectangle
y top coordinte of rectangle
w width of rectangle
h height of rectangle
model color model for bits
pixels array of bits
off offset for first element
scansize number of elements per row.

Overrides:

setPixels in class ImageFilter .


setProperties

public void setProperties(Hashtable  props) 

The image producer calls the setProperties method of the image consumer to let it know of additional properties of the image. For more information on this method and its arguments, see setProperties.

The setProperties method of CroppedImageFilter adds the property "croprect" with the value new Rectangle(x, y, width, height) to the table of properties, and then calls the setProperties method of its image consumer with the modified properties table.

ParameterDescription
props a hashtable that maps image properties to their value

Overrides:

setProperties in class ImageFilter .



Top© 1996 Sun Microsystems, Inc. All rights reserved.