Packages  This Package  Prev  Next  Index  

§2.2 Class CropImageFilter

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

        // Methods
    public void setDimensions(int  w, int  h);	§2.2.2
    public void setPixels(int  x, int  y, int  w, int  h,	§2.2.3
           ColorModel  model, byte  pixels[],
                    int  off, int  scansize);
    public void setPixels(int  x, int  y, int  w, int  h,	§2.2.4
           ColorModel  model, int  pixels[],
                    int  off, int  scansize);
    public void setProperties(Hashtable  props);	§2.2.5
}
The cropped image filter is an image filter for cropping images. This class extends the basic ImageFilter class (II-§2.5) 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 (II-§2.4) 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.
Parameters:
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 (II-§2.10.12) of its image consumer with the width and height arguments of the constructor (II-§2.2.1).

Parameters:
width - the width of the image
height - the height of the image
Overrides:
setDimensions in class ImageFilter (II-§2.5.8).

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 §2.10.14 on page 307.


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

Parameters:
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 (II-§2.5.10).

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 §2.10.15 on page 308.


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

Parameters:
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 (II-§2.5.11).

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 §2.10.16 on page 308.


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
(II-§2.10.16) with the modified properties table.

Parameters:
props - a hashtable that maps image properties to their value
Overrides:
setProperties in class ImageFilter (II-§2.5.12).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com