EarthWeb sites:
|
|
appendix G
java.awt.image
Package Reference
CONTENTS
While nearly all of the java.awt
package consists of graphical user interface components to be
used for screen layout, the java.awt.image
package contains classes that provide functionality for various
image transformations and operations.
The ImageConsumer interface
is implemented by objects interested in acquiring data provided
by the ImageProducer interface.
Member Variables
int RANDOMPIXELORDER
The pixels will be delivered in a random order.
int TOPDOWNLEFTRIGHT
The pixels will be delivered in top-down, left-right order.
int COMPLETESCANLINES
The pixels will be delivered in complete scan lines.
int SINGLEPASS
The pixels will be delivered in a single pass.
int SINGLEFRAME
The pixels will be delivered in a single frame.
int IMAGEERROR
An error occurred during image processing.
int SINGLEFRAMEDONE
A single frame is complete, but the overall operation has not
been completed.
int STATICIMAGEDONE
The image construction is complete.
int IMAGEABORTED
The image creation was aborted.
setDimensions
void setDimensions(int width, int height)
The setDimensions
method is used to report the dimensions of the source image to
the image consumer.
Parameters:
width-the width of
the source image.
height-the height of the
source image.
setProperties
void setProperties(Hashtable props)
The setProperties
method is used to report the properties of the source image to
the image consumer.
Parameters: props-a
Hashtable object containing
the image properties.
setColorModel
void setColorModel(ColorModel model)
The setColorModel
method is used to report the color model of the source image to
the image consumer.
Parameters: model-the
color model used by the source image.
setHints
void setHints(int hintflags)
The setHints
method is used to report hints to the image consumer.
Parameters: hintflags-an
integer value containing hints about the manner in which the pixels
will be delivered.
setPixels
void setPixels(int x, int y, int w, int h, ColorModel model, byte
pixels[],
int off, int scansize)
The setPixels method is used to deliver the pixels to the ImageConsumer.
Note: Pixel (x,y) is stored in the pixels array at index (y *
scansize + x + off).
Parameters:
x-the x coordinate.
y-the y coordinate.
w-the width of the image.
h-the height of the image.
model-the color model used.
pixels-an array of bytes containing pixel information.
off-the offset value.
scansize-the scansize value.
setPixels
void setPixels(int x, int y, int w, int h, ColorModel model,
int pixels[], int off, int scansize)
The setPixels method is used to deliver the pixels to the ImageConsumer.
Note: Pixel (x,y) is stored in the pixels array at index (y *
scansize + x + off).
Parameters:
x-the x coordinate.
y-the y coordinate.
w-the width of the image.
h-the height of the image.
model-the color model used.
pixels-an array of integers containing pixel information.
off-the offset value.
scansize-the scansize value.
imageComplete
void imageComplete(int status)
The imageComplete
method is called when the image producer is finished delivering
an image frame. The image consumer should remove itself from the
image producer's list at this time.
The ImageObserver interface
is an asynchronous update interface used to receive information
on the status of image construction.
Member Constants
public static final int WIDTH
The width of the base image is now available.
public static final int HEIGHT
The height of the base image is now available.
public static final int PROPERTIES
The properties of the base image are now available.
public static final int SOMEBITS
Some bits of the image for drawing are now available.
public static final int FRAMEBITS
Another complete frame of a multiframe image is now available.
public static final int ALLBITS
A static image that was previously drawn is now complete and can
be drawn again.
public static final int ERROR
An image that was being tracked asynchronously has encountered
an error.
public static final int ABORT
An image that was being tracked was aborted before production
was completed.
imageUpdate
public boolean imageUpdate(Image img,
int infoflags, int x,
int y, int width, int height)
The imageUpdate
method is called every time image information becomes available.
The recipients of the update messages are ImageObserver
objects that have requested information about an image using asynchronous
interfaces.
Parameters:
img-the image of interest.
infoflags-status flags indicating
the progress of the image process.
x-the x coordinate that applies
(if necessary).
y-the y coordinate that applies
(if necessary).
width-the width of the image
(if necessary).
height-the height of the
image (if necessary).
The ImageProducer interface
is implemented by objects that produce images. Each image contains
an image producer.
addConsumer
public void addConsumer(ImageConsumer
ic)
The addConsumer
method adds the image consumer to a list to receive image data
during reconstruction of the image.
Parameters: ic-an
ImageConsumer-derived object.
isConsumer
public boolean isConsumer(ImageConsumer
ic)
The isConsumer
method determines whether the specified image consumer is currently
on the image producer's list of recipients.
Parameters: ic-an
ImageConsumer-derived object
Returns: A boolean value that is true
if the image consumer is registered, false
if not.
removeConsumer
public void removeConsumer(ImageConsumer
ic)
The removeConsumer
method removes the specified image consumer from the internal
list.
Parameters: ic-an
ImageConsumer-derived object.
startProduction
public void startProduction(ImageConsumer
ic)
The startProduction
method adds the specified image consumer to the list of image
data recipients and immediately begins production of the image
data.
Parameters: ic-an
ImageConsumer-derived object.
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(ImageConsumer
ic)
The requestTopDownLeftRightResend
method is used to deliver the image data to the specified image
consumer in top-down, left-right order.
Parameters: ic-an
ImageConsumer-derived object.
Extends: Object
The ColorModel
class is an abstract class that provides functions for translating
pixel values into RGB color values.
ColorModel Constructor
public ColorModel(int bits)
The ColorModel
constructor constructs a color model that describes a pixel of
the specified number of bits.
Parameters: bits-an
integer value containing the number of bits that will describe
a pixel using this color model.
getRGBdefault
public static ColorModel getRGBdefault()
The getRGBdefault
method returns the default color model that is used throughout
all awt image interfaces. This default color model uses a pixel
format that encapsulates alpha, red, green, and blue color values
(8 bits each) using the following methodology: 0xAARRGGBB.
Returns: A ColorModel
object representing the default color model for all awt image
interfaces.
getPixelSize
public int getPixelSize()
The getPixelSize
method returns the size of the color model's pixel.
Returns: An integer value representing the number
of bits that make up a pixel in this color model.
getRed
public abstract int getRed(int pixel)
The getRed method
returns the red component of the specified pixel.
Parameters: pixel-an
integer containing the pixel representation for this color model.
Returns: An integer value representing the red component
of the pixel.
getGreen
public abstract int getGreen(int pixel)
The getGreen
method returns the green component of the specified pixel.
Parameters: pixel-an
integer containing the pixel representation for this color model.
Returns: An integer value representing the green
component of the pixel.
getBlue
public abstract int getBlue(int pixel)
The getBlue method
returns the blue component of the specified pixel.
Parameters: pixel-an
integer containing the pixel representation for this color model.
Returns: An integer value representing the blue
component of the pixel.
getAlpha
public abstract int getAlpha(int pixel)
The getAlpha
method returns the alpha component of the specified pixel.
Parameters: pixel-an
integer containing the pixel representation for this color model.
Returns: An integer value representing the alpha
component of the pixel.
getRGB
public int getRGB(int pixel)
The getRGB method
returns the RGB value of the pixel using the default color model.
Parameters: pixel-an
integer containing the pixel representation for this color model.
Returns: An integer value representing the RGB value
of the pixel using the default color model.
finalize
public void finalize()
The finalize
method is used to clean up internal data allocated by the ColorModel.
Extends: ImageFilter
The CropImageFilter class
provides the capability to extract a rectangular subset of a given
image (that is, crop it). This class is used in conjunction with
a FilteredImageSource class
to provide a source for the cropped image.
CropImageFilter Constructor
public CropImageFilter(int x, int y,
int w, int h)
The CropImageFilter
constructor constructs a CropImageFilter
to crop an image using the specified parameters.
Parameters:
x-the x coordinate of the
image to be cropped.
y-the y coordinate of the
image to be cropped.
w-the width of the image
to be cropped.
h-the height of the image
to be cropped.
setProperties
public void setProperties(Hashtable props)
The setProperties
method takes the props parameter
from a source object and adds the croprect
property to it to identify the region being cropped.
Parameters: props-a
Hashtable object containing
properties from the source object.
setDimensions
public void setDimensions(int w, int
h)
The setDimensions
method overrides the source's dimensions and passes the dimensions
of the cropped region to the ImageConsumer
interface.
Parameters:
w-the width value.
h-the height value.
setPixels
public void setPixels(int x, int y, int w, int h, ColorModel
model, int pixels[], int off, int scansize)
The setPixels method filters the pixels array by determining which
pixels lie in the cropped region. Those that do are passed on
to the Consumer interface.
Parameters:
x-the x coordinate of the image.
y-the y coordinate of the image.
w-the width of the image.
h-the height of the image.
model-the color model to which the pixels array conforms.
pixels-an array of integers containing pixels to be examined.
off-a variable that is passed on to the image consumer class's
setPixels method.
scansize-an integer value representing the scansize of the operation.
Extends: ColorModel
The DirectColorModel class specifies translations
from pixel values to RGB color values for pixels that have the
colors embedded directly in the pixel bits.
DirectColorModel Constructor
public DirectColorModel(int bits, int
rmask, int gmask, int bmask)
The DirectColorModel
constructor constructs a direct color model using the specified
parameters. DirectColorModels
built using this constructor have a default alphamask value of
255.
Parameters:
bits-the number of
bits used to represent a pixel.
rmask-the number of bits
required to represent the red component.
gmask-the number of bits
required to represent the green component.
bmask-the number of bits
required to represent the blue component.
DirectColorModel Constructor
public DirectColorModel(int bits, int
rmask, int gmask, int
bmask, int amask)
The DirectColorModel
constructor constructs a direct color model using the specified
parameters.
Parameters:
bits-the number of
bits used to represent a pixel.
rmask-the number of bits
required to represent the red component.
gmask-the number of bits
required to represent the green component.
bmask-the number of bits
required to represent the blue component.
amask-the number of bits
required to represent the alpha component.
getRedMask
final public int getRedMask()
The getRedMask
method returns the current red mask value.
Returns: An integer value representing the red mask
value.
getGreenMask
final public int getGreenMask()
The getGreenMask
method returns the current green mask value.
Returns: An integer value representing the green
mask value.
getBlueMask
final public int getBlueMask()
The getBlueMask
method returns the current blue mask value.
Returns: An integer value representing the blue
mask value.
getAlphaMask
final public int getAlphaMask()
The getAlphaMask
method returns the current alpha mask value.
Returns: An integer value representing the alpha
mask value.
getRed
final public int getRed(int pixel)
The getRed method
returns the red component for the specified pixel in the range
0-255.
Parameters: pixel-an
integer value representing a pixel under the direct color model.
Returns: An integer value representing the red component
of the pixel.
getGreen
final public int getGreen(int pixel)
The getGreen
method returns the green component for the specified pixel in
the range 0-255.
Parameters: pixel-an
integer value representing a pixel under the direct color model.
Returns: An integer value representing the green
component of the pixel.
getBlue
final public int getBlue(int pixel)
The getBlue method
returns the blue component for the specified pixel in the range
0-255.
Parameters: pixel-an
integer value representing a pixel under the direct color model.
Returns: An integer value representing the blue
component of the pixel.
getAlpha
final public int getAlpha(int pixel)
The getAlpha
method returns the alpha component for the specified pixel in
the range 0-255.
Parameters: pixel-an
integer value representing a pixel under the direct color model.
Returns: An integer value representing the alpha
component of the pixel.
getRGB
final public int getRGB(int pixel)
The getRGB method
returns the RGB color value for the specified pixel in the range
0-255.
Parameters: pixel-an
integer value representing a pixel under the direct color model.
Returns: An integer value representing the RGB color
value of the pixel using the default RGB color model.
Extends: Object
Implements: ImageProducer
FilteredImageSource takes as input an existing image
and a filter object. It applies the filter to the image to produce
a new version of the original image. The FilteredImageSource
class implements the ImageProducer
interface.
FilteredImageSource Constructor
public FilteredImageSource(ImageProducer
orig, ImageFilter imgf)
The FilteredImageSource
constructor constructs a FilteredImageSource
object that takes a producer source and an image filter to produce
a filtered version of the image.
Parameters:
orig-an ImageProducer-derived
object that supplies the image source.
imgf-an ImageFilter
object that filters the image to produce a new image.
addConsumer
public synchronized void addConsumer(ImageConsumer
ic)
The addConsumer
method adds an ImageConsumer
interface to a list of consumers interested in image data.
Parameters: ic-an
ImageConsumer-derived object
to be added to a list of image consumers.
isConsumer
public synchronized boolean isConsumer(ImageConsumer
ic)
The isConsumer
method determines whether the specified image consumer is currently
on the list of image consumers for the image data.
Parameters: ic-an
image consumer derived object to be used for the check.
Returns: A boolean value that is true
if the specified image consumer is on the list, false
if not.
removeConsumer
public synchronized void removeConsumer(ImageConsumer
ic)
The removeConsumer
method removes the specified image consumer from the list of image
consumers.
Parameters: ic-the
image consumer to be removed from the list.
startProduction
public void startProduction(ImageConsumer
ic)
The startProduction
method adds the specified image consumer to the list of image
consumers and immediately starts delivery of the image data to
the interface.
Parameters: ic-the
image consumer that will be used to produce new image data.
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(ImageConsumer
ic)
The requestTopDownLeftRightResend
method is used to deliver the image data to the specified image
consumer in top-down, left-right order.
Parameters: ic-the
image consumer that will be the recipient of the image data when
it is present.
Extends: Object
Implements: ImageConsumer,
Cloneable
The ImageFilter class acts
as a base class for all image-filtering classes. It implements
the ImageConsumer and Cloneable
interfaces.
getFilterInstance
public ImageFilter getFilterInstance(ImageConsumer
ic)
The getFilterInstance
method returns an ImageFilter
object that will be used to perform the filtering for the specified
image consumer.
Parameters: ic-the
image consumer that requires the image filtering.
Returns: An ImageFilter
object to be used to perform the image filtering.
setDimensions
public void setDimensions(int width,
int height}
The setDimensions
method filters the information provided in the setDimensions
method of the ImageConsumer
interface.
Parameters:
width-the filter width.
height-the filter height.
setProperties
public void setProperties(Hashtable props)
The setProperties
method passes the props value
along after a property is added that identifies which filters
have been applied to the image.
Parameters: props-a
Hashtable object containing
a set of properties.
setColorModel
public void setColorModel(ColorModel
model)
The setColorModel
method filters the information provided in the setColorModel
method of the ImageConsumer
interface.
Parameters: model-a
ColorModel object.
setHints
public void setHints(int hints)
The setHints
method filters the information provided in the setHints
method of the Image ImageConsumer
interface.
Parameters: hints-an
integer value containing hints.
setPixels
public void setPixels(int x, int y, int w, int h, ColorModel
model, byte pixels[], int off, int scansize)
The setPixels method filters the pixels array. The pixels that
pass through the filter are passed onto the ImageConsumer interface.
Parameters:
x-the x coordinate of the image.
y-the y coordinate of the image.
w-the width of the image.
h-the height of the image.
model-the ColorModel to which the pixels array conforms.
pixels-a byte array containing pixels to be examined.
off-a variable that is passed on to the image consumer's setPixels
method.
scansize-an integer value representing the scansize of the operation.
imageComplete
public void imageComplete(int status)
The imageComplete
method filters the information provided by the imageComplete
method in the ImageConsumer
interface.
Parameters: status-an
integer value representing the status of the filter operation
resendTopDownLeftRight
public void resendTopDownLeftRight(ImageProducer
ip)
The resendTopDownLeftRight
method is used to deliver the image data to the specified image
consumer in top-down, left-right order.
Parameters: ip-the
image producer that is responsible for production of the image
data.
clone
public Object clone()
The clone method
returns a clone of the image filter.
Returns: An object that is identical to the image
filter.
Extends: ColorModel
This class translates from pixel values to RGB color
values for pixels that represent indexes into a color map.
IndexColorModel Constructor
public IndexColorModel(int bits, int
size, byte r[], byte g[], byte b[])
The IndexColorModel
constructor constructs a color model from the specified information.
Parameters:
bits-the number of bits required
to represent a pixel.
size-the size of the color
arrays.
r-the red color array.
g-the green color array.
b-the blue color array.
IndexColorModel Constructor
public IndexColorModel(int bits, int
size, byte r[], byte g[], byte b[],
int trans)
The IndexColorModel
constructor constructs a color model from the specified information.
Parameters:
bits-the number of bits required
to represent a pixel.
size-the size of the color
arrays.
r-the red color array.
g-the green color array.
b-the blue color array.
trans-an integer value representing
the index that identifies the transparent pixel.
IndexColorModel Constructor
public IndexColorModel(int bits, int
size, byte r[], byte g[], byte b[],
byte a[])
The IndexColorModel
constructor constructs a color model from the specified information.
Parameters:
bits-the number of
bits required to represent a pixel.
size-the size of the color
arrays.
r-the red color array.
g-the green color array.
b-the blue color array.
a-the alpha color array.
IndexColorModel Constructor
public IndexColorModel(int bits, int
size, byte cmap[], int start,
boolean hasalpha)
The IndexColorModel
constructor constructs a color model from the specified information.
Parameters:
bits-the number of bits required
to represent a pixel.
size-the size of the color
arrays.
cmap-a byte array representing
the color map array.
start-the index representing
the first color component within the color array.
hasalpha-a boolean value
indicating whether alpha values are contained within the color
map.
IndexColorModel Constructor
public IndexColorModel(int bits, int
size, byte cmap[], int start,
boolean hasalpha, int trans)
The IndexColorModel
constructor constructs a color model from the specified information.
Parameters:
bits-the number of bits required
to represent a pixel.
size-the size of the color
arrays.
cmap-a byte array representing
the color map array.
start-the index representing
the first color component within the color array.
hasalpha-a boolean value
indicating whether alpha values are contained within the color
map.
trans-an integer value representing
the index of the transparent pixel.
getMapSize
final public int getMapSize()
The getMapSize
method returns the size of the color map used by the IndexColorModel.
Returns: An integer value representing the size
of the color map used by the index color model.
getTransparentPixel
final public int getTransparentPixel()
The getTransparentPixel
method returns the index into the color map of the transparent
pixel.
Returns: An integer value representing the index
into the color map of the transparent pixel. If there is no transparent
pixel, this method returns -1.
getReds
final public void getReds(byte r[])
The getReds method
fills the byte array with the red color components.
Parameters: r-a
byte array that is filled by the getReds
method with the red color components.
getGreens
final public void getGreens(byte g[])
The getGreens
method fills the byte array with the green color components.
Parameters: g-a
byte array that is filled by the getGreens
method with the green color components.
getBlues
final public void getBlues(byte b[])
The getBlues
method fills the byte array with the blue color components.
Parameters: b-a
byte array that is filled by the getBlues
method with the blue color components.
getAlphas
final public void getAlphas(byte a[])
The getAlphas
method fills the byte array with the alpha components.
Parameters: a-a
byte array that is filled by the getAlphas
method with the alpha components.
getRed
final public int getRed(int pixel)
The getRed method
returns the red color component for the specified pixel using
the index color model.
Parameters: pixel-an
integer value representing a pixel.
Returns: An integer value in the range 0-255 representing
the red component for the specified pixel.
getGreen
final public int getGreen(int pixel)
The getGreen
method returns the green color component for the specified pixel
using the index color model.
Parameters: pixel-an
integer value representing a pixel.
Returns: An integer value in the range 0-255 representing
the green component for the specified pixel.
getBlue
final public int getBlue(int pixel)
The getBlue method
returns the blue color component for the specified pixel using
the index color model.
Parameters: pixel-an
integer value representing a pixel.
Returns: An integer value in the range 0-255 representing
the blue component for the specified pixel.
getAlpha
final public int getAlpha(int pixel)
The getAlpha
method returns the alpha color component for the specified pixel
using the index color model.
Parameters: pixel-an
integer value representing a pixel.
Returns: An integer value in the range 0-255 representing
the alpha component for the specified pixel.
getRGB
final public int getRGB(int pixel)
The getRGB method
returns the RGB color value for the specified pixel using the
default RGB color model.
Parameters: pixel-an
integer value representing a pixel.
Returns: An integer value in the range 0-255 representing
the RGB color value for the specified pixel.
Extends: Object
Implements: ImageProducer
This class uses an array to produce image pixel values.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h,
ColorModel cm, byte[] pix, int off,
int scan)
The MemoryImageSource
constructor uses an array of bytes to produce image data for an
Image object.
Parameters:
w-the width of the
image to be created in pixels.
h-the height of the image
to be created in pixels.
cm-the color model used to
translate the pixel values.
pix-a byte array containing
the image data.
off-the offset into the array
to begin reading.
scan-the scan value.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h, ColorModel cm, byte[] pix,
int off,
int scan, Hashtable props)
The MemoryImageSource constructor uses an array of bytes to produce
image data for an Image object.
Parameters:
w-the width of the image to be created in pixels.
h-the height of the image to be created in pixels.
cm-the color model used to translate the pixel values.
pix-a byte array containing the image data.
off-the offset into the array to begin reading.
scan-the scan value.
props-a Hashtable object containing properties to be used by the
image producer.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h,
ColorModel cm, int[]
pix, int off, int scan)
The MemoryImageSource
constructor uses an array of bytes to produce image data for an
Image object.
Parameters:
w-the width of the image
to be created in pixels.
h-the height of the image
to be created in pixels.
cm-the color model used to
translate the pixel values.
pix-an integer array containing
the image data.
off-the offset into the array
to begin reading.
scan-the scan value.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h,
ColorModel cm, int[] pix, int off,
int scan, Hashtable props)
The MemoryImageSource constructor uses an array of
bytes to produce image data for an Image object.
Parameters:
w-the width of the image to be created in pixels.
h-the height of the image to be created in pixels.
cm-the color model used to translate the pixel values.
pix-an integer array containing the image data.
off-the offset into the array to begin reading.
scan-the scan value.
props-a Hashtable object containing properties to be used by the
image producer.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h,
int pix[], int off, int scan)
The MemoryImageSource
constructor uses an array of bytes to produce image data for an
Image object.
Parameters:
w-the width of the image
to be created in pixels.
h-the height of the image
to be created in pixels.
pix-an integer array containing
the image data.
off-the offset into the array
to begin reading.
scan-the scan value.
MemoryImageSource Constructor
public MemoryImageSource(int w, int h,
int pix[], int off, int scan,
Hashtable props)
The MemoryImageSource
constructor uses an array of bytes to produce image data for an
Image object.
Parameters:
w-the width of the image
to be created in pixels.
h-the height of the image
to be created in pixels.
pix-an integer array containing
the image data.
off-the offset into the array
to begin reading.
scan-the scan value.
props-a Hashtable
object containing properties to be used by the image producer.
addConsumer
public synchronized void addConsumer(ImageConsumer
ic)
The addConsumer
method adds an ImageConsumer
interface to a list of image consumers who are interested in data
for the image.
Parameters: ic-an
ImageConsumer-derived object.
isConsumer
public synchronized boolean isConsumer(ImageConsumer
ic)
The isConsumer
method determines if the specified image consumer is currently
in the list.
Parameters: ic-an
ImageConsumer-derived object.
Returns: A boolean value that is true
if the ImageConsumer object
is already in the list, false
if not.
removeConsumer
public synchronized void removeConsumer(ImageConsumer
ic)
The removeConsumer
method removes the specified image consumer from the list of image
consumers interested in receiving image data.
Parameters: ic-an
ImageConsumer-derived object.
startProduction
public void startProduction(ImageConsumer
ic)
The startProduction
method adds the specified image consumer to a list of image consumers
interested in receiving image data. This method also immediately
starts production of image data to be sent to the ImageConsumer
interfaces.
Parameters: ic-an
ImageConsumer-derived object.
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(ImageConsumer
ic)
The requestTopDownLeftRightResend
method is used to deliver the image data to the specified image
consumer in top-down, left-right order.
Parameters: ic-an
ImageConsumer-derived object.
Extends: Object
Implements: ImageConsumer
The PixelGrabber
class implements the ImageConsumer
interface to retrieve a subset of pixels from an image.
PixelGrabber Constructor
public PixelGrabber(Image img, int x,
int y, int w, int h, int[] pix, int off,
int scansize)
The PixelGrabber constructor constructs a PixelGrabber
object to retrieve a subset of pixels from the image. In this
case, the PixelGrabber will grab a rectangular section of pixels.
Parameters:
img-an Image object to be "grabbed."
x-the x coordinate from which to begin grabbing pixels.
y-the y coordinate from which to begin grabbing pixels.
w-the width of the PixelGrabber bounding rectangle.
h-the height of the PixelGrabber bounding rectangle.
pix-an array of integers used to store the grabbed pixels.
off-the offset into the image to begin calculations.
scan-an integer value used to represent the scansize.
PixelGrabber Constructor
public PixelGrabber(ImageProducer ip,
int x, int y, int w, int h, int[] pix,
int off, int scansize)
The PixelGrabber constructor constructs a PixelGrabber
object to retrieve a subset of pixels from the image. In this
case, the PixelGrabber will grab a rectangular section of pixels.
Parameters:
ip-an ImageProducer object to be grabbed.
x-the x coordinate from which to begin grabbing pixels.
y-the y coordinate from which to begin grabbing pixels.
w-the width of the PixelGrabber bounding rectangle.
h-the height of the PixelGrabber bounding rectangle.
pix-an array of integers used to store the grabbed pixels.
off-the offset into the image to begin calculations.
scan-an integer value used to represent the scansize.
grabPixels
public boolean grabPixels() throws InterruptedException
The grabPixels
method notifies the pixel grabber to begin grabbing pixels and
wait until all of the pixels to be grabbed have been delivered.
Returns: A boolean value that is true
if the operation was successful, false
if not.
Throws: InterruptedException
if the process was interrupted.
grabPixels
public synchronized boolean grabPixels(long
ms) throws InterruptedException
This grabPixels
method notifies the pixel grabber to begin grabbing pixels at
some specified time in the future and wait until all of the pixels
to be grabbed have been delivered.
Parameters: ms-a
long integer value representing the start time in milliseconds.
Returns: A boolean value that is true
if the operation was successful, false
if not.
Throws: InterruptedException
if the process was interrupted.
status
public synchronized int status()
The status method
returns a value representing the status of the grab operation.
Returns: An integer value representing the operation's
status. This value will be a bitwise OR
of all relevant image observer flags.
setDimensions
public void setDimensions(int width,
int height)
The setDimensions
method must be implemented by this class to fulfill its interface
with the ImageConsumer interface.
Parameters: width-the
width parameter.
Parameters: height-the
height parameter.
setHints
public void setHints(int hints)
The setHints
method must be implemented by this class to fulfill its interface
with the ImageConsumer interface.
Parameters: hints-the
hints parameter.
setProperties
public void setProperties(Hashtable props)
The setProperties
method must be implemented by this class to fulfill its interface
with the ImageConsumer interface.
Parameters: props-a
Hashtable object.
setColorModel
public void setColorModel(ColorModel
model)
The setColorModel
method must be implemented by this class to fulfill its interface
with the ImageConsumer interface.
Parameters: model-a
ColorModel object.
setPixels
public void setPixels(int srcX, int srcY,
int srcW, int srcH,
ColorModel model, byte pixels[], int srcOff, int srcScan)
The setPixels method must be implemented by this class
to fulfill its interface with the ImageConsumer interface.
Parameters:
srcX-an integer value representing the source x coordinate.
srcY-an integer value representing the source y coordinate.
srcW-an integer value representing the source width.
srcH-an integer value representing the source height.
model-the color model to be used.
pixels-a byte array of pixel values.
srcOff-the offset into the source array.
srcScan-the source scan value.
imageComplete
public synchronized void imageComplete(int
status)
The imageComplete
method must be implemented by this class to fulfill its interface
with the ImageConsumer interface.
Parameters: status-an
integer value representing the status of the pixel grab operation.
Extends: ImageFilter
The RGBImageFilter abstract class provides the functionality
to process image data within a single method which converts pixels
in the default RGB ColorModel.setColorModel
SetColorModel
public void setColorModel(ColorModel
model)
The setColorModel
method checks the type of the specified color model. If it is
an IndexColorModel and the
protected canFilterIndexColorModel
variable is true, the color
model will be set to the IndexColorModel.
Otherwise, the default RGB color model will be used for all filtering
operations.
Parameters: Model-the
color model to be used for filtering.
substituteColorModel
public void substituteColorModel(ColorModel
oldcm, ColorModel newcm)
The substituteColorModel
method allows color models to be interchanged on-the-fly. If the
old color model is encountered during a setPixels
method call, the new color model will be used instead.
Parameters:
oldcm-the old color model
to be replaced.
newcm-the new color model.
filterIndexColorModel
public IndexColorModel filterIndexColorModel(IndexColorModel
icm)
The filterIndexColorModel method runs each entry in
the specified IndexColorModel through the filterRGB method and
returns a new color model.
Parameters: icm-the IndexColorModel object to be
filtered.
Returns: An IndexColorModel object that has been
filtered by the RGBImageFilter class.
filterRGBPixels
public void filterRGBPixels(int x, int
y, int w, int h, int pixels[], int off,
int scansize)
The filterRGBPixels
method filters an array of pixels through the filterRGB
method.
Parameters:
x-the x coordinate from which
to start the filtering.
y-the y coordinate from which
to start the filtering.
w-the width of the image
to be filtered.
h-the height of the image
to be filtered.
pixels-an array of integers
representing pixel values.
off-the offset used.
scansize-the scansize used.
setPixels
public void setPixels(int x, int y, int
w, int h, ColorModel model,
int pixels[], int off, int scansize)
The setPixels
method converts the pixels and color model before passing them
on. If the color model has already been converted, the pixels
are passed through with the converted color model. If not, then
the pixel array is converted to the default RGB color model using
the filterRGBPixels method.
Parameters:
x-the x coordinate from which
to start the filtering.
y-the y coordinate from which
to start the filtering.
w-the width of the image
to be filtered.
h-the height of the image
to be filtered.
model-the color model with
which the pixels comply.
pixels-an array of integers
representing pixel values.
off-the offset used.
scansize-the scansize used.
filterRGB
public abstract int filterRGB(int x,
int y, int rgb)
The filterRGB
method allows subclasses to specify a method that converts an
input pixel using the default RGB color model to an output pixel.
Parameters:
x-the x coordinate of the
pixel.
y-the y coordinate of the
pixel.
rgb-the pixel value using
the default RGB color model.
Returns: An integer value representing the filtered
pixel value.
|