Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.image.DirectColorModel

java.lang.Object
    |
    +----java.awt.image.ColorModel
            |
            +----java.awt.image.PackedColorModel
                    |
                    +----java.awt.image.DirectColorModel

public class DirectColorModel
extends PackedColorModel
A ColorModel class that represents pixel values that have RGB color components embedded directly in the bits of the pixel itself. This color model is similar to an X11 TrueColor visual. The default RGB ColorModel specified by the ColorModel.getRGBdefault method is a DirectColorModel with the following parameters:
 Number of bits:        32
 Red mask:              0x00ff0000
 Green mask:            0x0000ff00
 Blue mask:             0x000000ff
 Alpha mask:            0xff000000
 Color space:           sRGB
 isAlphaPremultiplied:  False
 

Many of the methods in this class are final. This is because the underlying native graphics code makes assumptions about the layout and operation of this class and those assumptions are reflected in the implementations of the methods here that are marked final. You can subclass this class for other reasons, but you cannot override or modify the behaviour of those methods.

See Also:
ColorModel, ColorSpace

Fields inherited from class java.awt.image.ColorModel
 pixel_bits, transferType
 

Constructor Summary
 DirectColorModel(int bits, int rmask, int gmask, int bmask)
Constructs a DirectColorModel from the given masks specifying which bits in the pixel contain the red, green and blue color components.
 DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask)
Constructs a DirectColorModel from the given masks specifying which bits in the pixel contain the alpha, red, green and blue color components.
 DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied)
Constructs a DirectColorModel from the specified parameters.
 

Method Summary
ColorModel  coerceData(WritableRaster raster, boolean isAlphaPremultiplied)
Forces the Raster data to match the state specified in the isAlphaPremultiplied variable, assuming the data is currently correctly described by this ColorModel.
WritableRaster  createCompatibleWritableRaster(int w, int h)
Creates a WritableRaster with the specified width and height, that has a channel layout compatible with this ColorModel.
int  getAlpha(int pixel)
Return the alpha transparency value for the specified pixel in the range 0-255.
int  getAlpha(Object inData)
Returns the alpha color component for the specified pixel, scaled from 0 to 255.
int  getAlphaMask()
Returns the mask indicating which bits in a pixel contain the alpha transparency component.
int  getBlue(int pixel)
Returns the blue color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB.
int  getBlue(Object inData)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
int  getBlueMask()
Returns the mask indicating which bits in a pixel contain the blue color component.
int[]  getComponents(int pixel, int[] components, int offset)
Returns an array of all of the components given a pixel in the current color model.
int[]  getComponents(Object obj, int[] components, int offset)
Returns an array of all of the components given a pixel array in the current color model.
int  getGreen(int pixel)
Returns the green color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB.
int  getGreen(Object inData)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
int  getGreenMask()
Returns the mask indicating which bits in a pixel contain the green color component.
Object  getPixelData(int rgb, Object inData)
Returns a pixel array of type transferType by object reference given a pixel in the default RGB color model.
int  getRed(int pixel)
Returns the red color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB.
int  getRed(Object inData)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
int  getRedMask()
Returns the mask indicating which bits in a pixel contain the red color component.
int  getRGB(int pixel)
Returns the color of the pixel in the default RGB color model.
int  getRGB(Object inData)
Returns a pixel in the default RGB color model given a pixel in the current color model.
boolean  isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel and false if it is not.
int  setComponents(int[] components, int offset)
This method will pack the components into a pixel given an array of discrete components in this color model.
Object  setComponents(int[] components, int offset, Object obj)
This method will pack the components into a pixel given an array of discrete components in this color model.
String  toString()
 
 
Methods inherited from class java.awt.image.PackedColorModel
 equals, getMask, getMask
 
Methods inherited from class java.awt.image.ColorModel
 coerceData, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlpha, getBlue, getBlue, getColorSpace, getComponents, getComponents, getComponents, getComponentSize, getComponentSize, getGreen, getGreen, getMaxComponentSize, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelData, getPixelSize, getRed, getRed, getRGB, getRGB, getRGBdefault, getTransparency, hasAlpha, isAlphaPremultiplied, isCompatibleRaster, setComponents, setComponents, toString
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectColorModel

public DirectColorModel(int bits,
                        int rmask,
                        int gmask,
                        int bmask)
Constructs a DirectColorModel from the given masks specifying which bits in the pixel contain the red, green and blue color components. Pixels described by this color model will all have alpha components of 255 (fully opaque). All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of the integer.

DirectColorModel

public DirectColorModel(int bits,
                        int rmask,
                        int gmask,
                        int bmask,
                        int amask)
Constructs a DirectColorModel from the given masks specifying which bits in the pixel contain the alpha, red, green and blue color components. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of the integer. The ColorSpace will be the default sRGB space, and alpha, if present, will not be premultiplied.

DirectColorModel

public DirectColorModel(ColorSpace space,
                        int bits,
                        int rmask,
                        int gmask,
                        int bmask,
                        int amask,
                        boolean isAlphaPremultiplied)
Constructs a DirectColorModel from the specified parameters. The masks specify which bits in the pixel contain the alpha, red, green and blue color components. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of the integer. The ColorSpace of the color model is specified by space and must be of ColorSpace.TYPE_RGB. If there is alpha, the boolean, isAlphaPremultiplied, specifies how to interpret color data that are passed to this ColorModel. If it is true, the color data will have been multiplied with alpha.
Method Detail

getRedMask

public final int getRedMask()
Returns the mask indicating which bits in a pixel contain the red color component.

getGreenMask

public final int getGreenMask()
Returns the mask indicating which bits in a pixel contain the green color component.

getBlueMask

public final int getBlueMask()
Returns the mask indicating which bits in a pixel contain the blue color component.

getAlphaMask

public final int getAlphaMask()
Returns the mask indicating which bits in a pixel contain the alpha transparency component.

getRed

public final int getRed(int pixel)
Returns the red color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getRed in class ColorModel

getGreen

public final int getGreen(int pixel)
Returns the green color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getGreen in class ColorModel

getBlue

public final int getBlue(int pixel)
Returns the blue color component for the specified pixel in the range 0-255 in the default RGB ColorSpace, sRGB. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getBlue in class ColorModel

getAlpha

public final int getAlpha(int pixel)
Return the alpha transparency value for the specified pixel in the range 0-255.
Overrides:
getAlpha in class ColorModel

getRGB

public final int getRGB(int pixel)
Returns the color of the pixel in the default RGB color model. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned).
Overrides:
getRGB in class ColorModel
See Also:
getRGBdefault

getRed

public int getRed(Object inData)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getRed in class ColorModel

getGreen

public int getGreen(Object inData)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getGreen in class ColorModel

getBlue

public int getBlue(Object inData)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getBlue in class ColorModel

getAlpha

public int getAlpha(Object inData)
Returns the alpha color component for the specified pixel, scaled from 0 to 255. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference.
Overrides:
getAlpha in class ColorModel

getRGB

public int getRGB(Object inData)
Returns a pixel in the default RGB color model given a pixel in the current color model. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. The returned value will be a non pre-multiplied color (i.e. if the alpha is premultiplied, this method will divide it out before it is returned). If the alpha value is 0, the color will be 0.
Overrides:
getRGB in class ColorModel
See Also:
getRGBdefault

getPixelData

public Object getPixelData(int rgb,
                           Object inData)
Returns a pixel array of type transferType by object reference given a pixel in the default RGB color model. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. This pixel array can then be passed to the setPixelData method of a Raster object. If the pixel variable is null, a new array will be allocated. The pixel array will be returned.
Overrides:
getPixelData in class ColorModel

getComponents

public final int[] getComponents(int pixel,
                                 int[] components,
                                 int offset)
Returns an array of all of the components given a pixel in the current color model. This can be used to retrieve the components for a specific pixel in a PackedColorModel. If the components array is null, a new array will be allocated. The components array will be returned.
Overrides:
getComponents in class ColorModel

getComponents

public final int[] getComponents(Object obj,
                                 int[] components,
                                 int offset)
Returns an array of all of the components given a pixel array in the current color model. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. This can be used to retrieve the components for a specific pixel in a PackedColorModel. If the components array is null, a new array will be allocated. The components array will be returned.
Overrides:
getComponents in class ColorModel

createCompatibleWritableRaster

public final WritableRaster createCompatibleWritableRaster(int w,
                                                           int h)
Creates a WritableRaster with the specified width and height, that has a channel layout compatible with this ColorModel.
Overrides:
createCompatibleWritableRaster in class ColorModel
See Also:
WritableRaster

setComponents

public int setComponents(int[] components,
                         int offset)
This method will pack the components into a pixel given an array of discrete components in this color model. This method will throw an IllegalArgumentException if the components cannot fit in a single integer pixel.
Overrides:
setComponents in class ColorModel

setComponents

public Object setComponents(int[] components,
                            int offset,
                            Object obj)
This method will pack the components into a pixel given an array of discrete components in this color model. The pixel is described by a discrete array of data elements of type transferType passed in as an object reference. This array can be passed to the setPixelData methods of Raster. objects.
Overrides:
setComponents in class ColorModel

coerceData

public final ColorModel coerceData(WritableRaster raster,
                                   boolean isAlphaPremultiplied)
Forces the Raster data to match the state specified in the isAlphaPremultiplied variable, assuming the data is currently correctly described by this ColorModel. It may multiply or divide the color Raster data by alpha, or do nothing if the data is in the correct state. If the data needs to be coerced, this method will also return an instance of this ColorModel with the isAlphaPremultiplied flag set appropriately.
Overrides:
coerceData in class ColorModel

isCompatibleRaster

public boolean isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel and false if it is not.
Overrides:
isCompatibleRaster in class ColorModel

toString

public String toString()
Overrides:
toString in class ColorModel

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.