Thứ Sáu, 28 tháng 2, 2014

Tài liệu Introduction to Java: 22 java.awt.image Reference docx

getBlue
public abstract int getBlue (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current blue setting of the pixel.
getGreen
public abstract int getGreen (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current green setting of the pixel.
getPixelSize
public int getPixelSize()
Returns The current pixel size for the color model.
getRed
public abstract int getRed (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current red setting of the pixel.
getRGB
public int getRGB (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current combined red, green, and blue settings of the
pixel.
Description Gets the color of pixel in the default RGB color model.
See Also
DirectColorModel, IndexColorModel, Object
22.3 CropImageFilter
Description
The CropImageFilter class creates a smaller image by cropping (i.e., extracting
a rectangular region from) a larger image.
CROPIMAGEFILTER 901
10 July 2002 22:26
Class Definition
public class java.awt.image.CropImageFilter
extends java.awt.image.ImageFilter {
// Constructors
public CropImageFilter (int x, int y, int width, int height);
// Instance Methods
public void setDimensions (int width, int height);
public void setPixels (int x, int y, int width, int height, ColorModel model,
byte[] pixels, int offset, int scansize);
public void setPixels (int x, int y, int width, int height, ColorModel model,
int[] pixels, int offset, int scansize);
public void setProperties (Hashtable properties);
}
Constructors
CropImageFilter
public CropImageFilter (int x, int y, int width, int
height)
Parameters x x-coordinate of top-left corner of piece to crop.
y y-coordinate of top-left corner of piece to crop.
width Width of image to crop.
height Height of image to crop.
Description Constructs a CropImageFilter that crops the specified region
from the original image.
Instance Methods
setDimensions
public void setDimensions (int width, int height)
Parameters width Ignored parameter.
height Ignored parameter.
Overrides ImageFilter.setDimensions(int, int)
Description Called with the original image’s dimensions; these dimensions
are ignored. The method in turn calls the ImageConsumer
with the dimensions of the cropped image.
setPixels
902 CROPIMAGEFILTER
10 July 2002 22:26
public void setPixels (int x, int y, int width, int
height, ColorModel model, byte[] pixels, int offset, int
scansize)
Parameters x x-coordinate of top-left corner of pixel data
delivered with this method call.
y y-coordinate of top-left corner of pixel data
delivered with this method call.
width Width of the rectangle of pixel data delivered
with this method call.
height Height of the rectangle of pixel data delivered
with this method call.
model Color model of image data.
pixels Image data.
offset Offset from beginning of the pixels array.
scansize Size of each line of data in pixels array.
Overrides
ImageFilter.setPixels(int, int, int, int,
ColorModel, byte[], int, int)
Description Receives a rectangle of image data from the ImageProducer;
crops these pixels and delivers them to any ImageConsumers.
public void setPixels (int x, int y, int width, int
height, ColorModel model, int[] pixels, int offset, int
scansize)
Parameters x x-coordinate of top-left corner of pixel data
delivered with this method call.
y y-coordinate of top-left corner of pixel data
delivered with this method call.
width Width of the rectangle of pixel data delivered
with this method call.
height Height of the rectangle of pixel data delivered
with this method call.
model Color model of image data.
pixels Image data.
offset Offset from beginning of the pixels array.
scansize Size of each line of data in pixels array.
Overrides ImageFilter.setPixels(int, int, int, int,
ColorModel, int[], int, int)
Description Receives a rectangle of image data from the ImageProducer;
crops these pixels and delivers them to any ImageConsumers.
CROPIMAGEFILTER 903
10 July 2002 22:26
setProperties
public void setProperties (Hashtable properties)
Parameters properties The properties for the image.
Overrides ImageFilter.setProperties(Hashtable)
Description Adds the “croprect” image property to the properties list.
See Also
ColorModel, Hashtable, ImageFilter
22.4 DirectColorModel
Description
The DirectColorModel class provides a ColorModel that specifies a translation
between pixels and alpha, red, green, and blue component values, where the color
values are embedded directly within the pixel.
Class Definition
public class java.awt.image.DirectColorModel
extends java.awt.image.ColorModel {
// Constructors
public DirectColorModel (int bits, int redMask, int greenMask,
int blueMask);
public DirectColorModel (int bits, int redMask, int greenMask,
int blueMask,
int alphaMask);
// Instance Methods
public final int getAlpha (int pixel);
public final int getAlphaMask();
public final int getBlue (int pixel);
public final int getBlueMask();
public final int getGreen (int pixel);
public final int getGreenMask()
public final int getRed (int pixel);
public final int getRedMask();
public final int getRGB (int pixel);
}
904 CROPIMAGEFILTER
10 July 2002 22:26
Constructors
DirectColorModel
public DirectColorModel (int bits, int redMask, int
greenMask, int blueMask)
Parameters bits The number of bits required per pixel of an
image using this model.
redMask The location of the red component of a pixel.
greenMask The location of the green component of a pixel.
blueMask The location of the blue component of a pixel.
Throws
IllegalArgumentException
If the mask bits are not contiguous or overlap.
Description Constructs a DirectColorModel object with the given size
and color masks; the alpha (transparency) component is not
used.
public DirectColorModel (int bits, int redMask, int
greenMask, int blueMask, int alphaMask)
Parameters bits The number of bits required per pixel of an
image using this model.
redMask The location of the red component of a pixel.
greenMask The location of the green component of a pixel.
blueMask The location of the blue component of a pixel.
alphaMask The location of the alpha component of a pixel.
Throws IllegalArgumentException
If the mask bits are not contiguous or overlap.
Description Constructs a DirectColorModel object with the given size
and color masks.
Instance Methods
getAlpha
public final int getAlpha (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current alpha setting of the pixel.
Overrides ColorModel.getAlpha(int)
getAlphaMask
DIRECTCOLORMODEL 905
10 July 2002 22:26
public final int getAlphaMask()
Returns The current alpha mask setting of the color model.
getBlue
public final int getBlue (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current blue setting of the pixel.
Overrides ColorModel.getBlue(int)
getBlueMask
public final int getBlueMask()
Returns The current blue mask setting of the color model.
getGreen
public final int getGreen (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current green setting of the pixel.
Overrides ColorModel.getGreen(int)
getGreenMask
public final int getGreenMask()
Returns The current green mask setting of the color model.
getRed
public final int getRed (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current red setting of the pixel.
Overrides ColorModel.getRed(int)
getRedMask
public final int getRedMask()
Returns The current red mask setting of the color model.
getRGB
906 DIRECTCOLORMODEL
10 July 2002 22:26
public final int getRGB (int pixel)
Parameters pixel A pixel encoded with this ColorModel.
Returns The current combined red, green, and blue settings of the
pixel.
Overrides
ColorModel.getRGB(int)
Description Gets the color of pixel in the default RGB color model.
See Also
ColorModel
22.5 FilteredImageSource
Description
The FilteredImageSource class acts as glue to put an original ImageProducer
and ImageFilter together to create a new image. As the ImageProducer for the
new image, FilteredImageSource is responsible for registering image con-
sumers for the new image.
Class Definition
public class java.awt.image.FilteredImageSource
extends java.lang.Object
implements java.awt.image.ImageProducer {
// Constructors
public FilteredImageSource (ImageProducer original,
ImageFilter filter);
// Instance Methods
public synchronized void addConsumer (ImageConsumer ic);
public synchronized boolean isConsumer (ImageConsumer ic);
public synchronized void removeConsumer (ImageConsumer ic);
public void requestTopDownLeftRightResend (ImageConsumer ic);
public void startProduction (ImageConsumer ic);
}
Constructors
FilteredImageSource
public FilteredImageSource (ImageProducer original,
ImageFilter filter)
FILTEREDIMAGESOURCE 907
10 July 2002 22:26
Parameters original An ImageProducer that generates the image to
be filtered.
filter The ImageFilter to use to process image data
delivered by original.
Description Constructs a FilteredImageSource object to filter an image
generated by an ImageProducer.
Class Methods
addConsumer
public synchronized void addConsumer (ImageConsumer ic)
Parameters ic ImageConsumer interested in receiving the new
image.
Implements ImageProducer.addConsumer(ImageConsumer)
Description Registers an ImageConsumer as interested in Image
information.
isConsumer
public synchronized boolean isConsumer (ImageConsumer ic)
Parameters ic ImageConsumer to check.
Returns true if ImageConsumer is registered with this ImagePro-
ducer
, false other wise.
Implements ImageProducer.isConsumer(ImageConsumer)
removeConsumer
public synchronized void removeConsumer (ImageConsumer ic)
Parameters ic ImageConsumer to remove.
Implements ImageProducer.removeConsumer(ImageConsumer)
Description Removes an ImageConsumer from the registered consumers
for this ImageProducer.
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend (ImageConsumer
ic)
Parameters ic ImageConsumer to communicate with.
Implements ImageProducer.requestTopDownLeftRightResend()
Description Requests the retransmission of the Image data in top-down,
left-to-right order.
908 FILTEREDIMAGESOURCE
10 July 2002 22:26
startProduction
public void startProduction (ImageConsumer ic)
Parameters ic ImageConsumer to communicate with.
Implements ImageProducer.startProduction(ImageConsumer)
Description Registers ImageConsumer as interested in Image information
and tells ImageProducer to start creating the filtered Image
data immediately.
See Also
ImageFilter, ImageConsumer, ImageProducer, Object
22.6 ImageConsumer
Description
ImageConsumer is an interface that provides the means to consume pixel data
and render it for display.
Interface Definition
public abstract interface java.awt.image.ImageConsumer {
// Constants
public final static int COMPLETESCANLINES;
public final static int IMAGEABORTED;
public final static int IMAGEERROR;
public final static int RANDOMPIXELORDER;
public final static int SINGLEFRAME;
public final static int SINGLEFRAMEDONE;
public final static int SINGLEPASS;
public final static int STATICIMAGEDONE;
public final static int TOPDOWNLEFTRIGHT;
// Interface Methods
public abstract void imageComplete (int status);
public abstract void setColorModel (ColorModel model);
public abstract void setDimensions (int width, int height);
public abstract void setHints (int hints);
public abstract void setPixels (int x, int y, int width, int height,
ColorModel model, byte[] pixels, int offset, int scansize);
public abstract void setPixels (int x, int y, int width, int height,
ColorModel model, int[] pixels, int offset, int scansize);
public abstract void setProperties (Hashtable properties);
}
IMAGECONSUMER 909
10 July 2002 22:26
Constants
COMPLETESCANLINES
public final static int COMPLETESCANLINES
Hint flag for the setHints(int) method; indicates that the image will be
delivered one or more scanlines at a time.
IMAGEABORTED
public final static int IMAGEABORTED
Status flag for the imageComplete(int) method indicating that the loading
process for the image aborted.
IMAGEERROR
public final static int IMAGEERROR
Status flag for the imageComplete(int) method indicating that an error
happened during image loading.
RANDOMPIXELORDER
public final static int RANDOMPIXELORDER
Hint flag for the setHints(int) method; indicates that the pixels will be
delivered in no particular order.
SINGLEFRAME
public final static int SINGLEFRAME
Hint flag for the setHints(int) method; indicates that the image consists of
a single frame.
SINGLEFRAMEDONE
public final static int SINGLEFRAMEDONE
Status flag for the imageComplete(int) method indicating a single frame of
the image has loaded.
SINGLEPASS
public final static int SINGLEPASS
Hint flag for the setHints(int) method; indicates that each pixel will be
delivered once (i.e., the producer will not make multiple passes over the
image).
910 IMAGECONSUMER
10 July 2002 22:26

Không có nhận xét nào:

Đăng nhận xét