- All Implemented Interfaces:
- Transparency
DirectColorModel class is a ColorModel
 class that works with pixel values that represent RGB
 color and alpha information as separate samples and that pack all
 samples for a single pixel into a single int, short, or byte quantity.
 This class can be used only with ColorSpaces of type ColorSpace.TYPE_RGB.
 In addition, for each component of the ColorSpace, the minimum
 normalized component value obtained via the getMinValue()
 method of ColorSpace must be 0.0, and the maximum value obtained via
 the getMaxValue() method must be 1.0 (these min/max
 values are typical for RGB spaces).
 There must be three color samples in the pixel values and there can
 be a single alpha sample.  For those methods that use a primitive array
 pixel representation of type transferType, the array
 length is always one.  The transfer
 types supported are DataBuffer.TYPE_BYTE,
 DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT.
 Color and alpha samples are stored in the single
 element of the array in bits indicated by bit masks.  Each bit mask
 must be contiguous and masks must not overlap.  The same masks apply to
 the single int pixel representation used by other methods.  The
 correspondence of masks and color/alpha samples is as follows:
 - Masks are identified by indices running from 0 through 2 if no alpha is present, or 3 if an alpha is present.
- The first three indices refer to color samples; index 0 corresponds to red, index 1 to green, and index 2 to blue.
- Index 3 corresponds to the alpha sample, if present.
 The translation from pixel values to color/alpha components for
 display or processing purposes is a one-to-one correspondence of
 samples to components.  A DirectColorModel is
 typically used with image data which uses masks to define packed
 samples.  For example, a DirectColorModel can be used in
 conjunction with a SinglePixelPackedSampleModel to
 construct a BufferedImage.  Normally the masks used by the
 SampleModel and the ColorModel would be the
 same.  However, if they are different, the color interpretation
 of pixel data will be done according to the masks of the
 ColorModel.
 
 A single int pixel representation is valid for all objects of this
 class, since it is always possible to represent pixel values used with
 this class in a single int.  Therefore, methods which use this
 representation will not throw an IllegalArgumentException
 due to an invalid pixel value.
 
 This color model is similar to an X11 TrueColor visual.
 The default RGB ColorModel specified by the
 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 Transparency: Transparency.TRANSLUCENT transferType: DataBuffer.TYPE_INT
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 behavior of those methods.
- 
Field SummaryFields declared in class java.awt.image.ColorModelpixel_bits, transferTypeFields declared in interface java.awt.TransparencyBITMASK, OPAQUE, TRANSLUCENT
- 
Constructor SummaryConstructorsConstructorDescriptionDirectColorModel(int bits, int rmask, int gmask, int bmask) Constructs aDirectColorModelfrom the specified masks that indicate which bits in anintpixel representation contain the red, green and blue color samples.DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask) Constructs aDirectColorModelfrom the specified masks that indicate which bits in anintpixel representation contain the red, green and blue color samples and the alpha sample, if present.DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType) Constructs aDirectColorModelfrom the specified parameters.
- 
Method SummaryModifier and TypeMethodDescriptionfinal ColorModelcoerceData(WritableRaster raster, boolean isAlphaPremultiplied) Forces the raster data to match the state specified in theisAlphaPremultipliedvariable, assuming the data is currently correctly described by thisColorModel.final WritableRastercreateCompatibleWritableRaster(int w, int h) Creates aWritableRasterwith the specified width and height that has a data layout (SampleModel) compatible with thisColorModel.final intgetAlpha(int pixel) Returns the alpha component for the specified pixel, scaled from 0 to 255.intReturns the alpha component for the specified pixel, scaled from 0 to 255.final intReturns the mask indicating which bits in anintpixel representation contain the alpha component.final intgetBlue(int pixel) Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.intReturns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.final intReturns the mask indicating which bits in anintpixel representation contain the blue color component.final int[]getComponents(int pixel, int[] components, int offset) Returns an array of unnormalized color/alpha components given a pixel in thisColorModel.final int[]getComponents(Object pixel, int[] components, int offset) Returns an array of unnormalized color/alpha components given a pixel in thisColorModel.intgetDataElement(int[] components, int offset) Returns a pixel value represented as anintin thisColorModel, given an array of unnormalized color/alpha components.getDataElements(int[] components, int offset, Object obj) Returns a data element array representation of a pixel in thisColorModel, given an array of unnormalized color/alpha components.getDataElements(int rgb, Object pixel) Returns a data element array representation of a pixel in thisColorModel, given an integer pixel representation in the default RGB color model.final intgetGreen(int pixel) Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.intReturns the green color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.final intReturns the mask indicating which bits in anintpixel representation contain the green color component.final intgetRed(int pixel) Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.intReturns the red color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB.final intReturns the mask indicating which bits in anintpixel representation contain the red color component.final intgetRGB(int pixel) Returns the color/alpha components of the pixel in the default RGB color model format.intReturns the color/alpha components for the specified pixel in the default RGB color model format.booleanisCompatibleRaster(Raster raster) Returnstrueifrasteris compatible with thisColorModelandfalseif it is not.toString()Returns aStringthat represents thisDirectColorModel.Methods declared in class java.awt.image.PackedColorModelcreateCompatibleSampleModel, equals, getAlphaRaster, getMask, getMasks, hashCode, isCompatibleSampleModelMethods declared in class java.awt.image.ColorModelgetColorSpace, getComponentSize, getComponentSize, getDataElement, getDataElements, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, isAlphaPremultiplied
- 
Constructor Details- 
DirectColorModelpublic DirectColorModel(int bits, int rmask, int gmask, int bmask) Constructs aDirectColorModelfrom the specified masks that indicate which bits in anintpixel representation contain the red, green and blue color samples. As pixel values do not contain alpha information, all pixels are treated as opaque, which means that alpha = 1.0. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of anintpixel representation. TheColorSpaceis the default sRGB space. The transparency value is Transparency.OPAQUE. The transfer type is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT that can hold a single pixel.- Parameters:
- bits- the number of bits in the pixel values; for example, the sum of the number of bits in the masks.
- rmask- specifies a mask indicating which bits in an integer pixel contain the red component
- gmask- specifies a mask indicating which bits in an integer pixel contain the green component
- bmask- specifies a mask indicating which bits in an integer pixel contain the blue component
 
- 
DirectColorModelpublic DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask) Constructs aDirectColorModelfrom the specified masks that indicate which bits in anintpixel representation contain the red, green and blue color samples and the alpha sample, if present. Ifamaskis 0, pixel values do not contain alpha information and all pixels are treated as opaque, which means that alpha = 1.0. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of anintpixel representation. Alpha, if present, is not premultiplied. TheColorSpaceis the default sRGB space. The transparency value is Transparency.OPAQUE if no alpha is present, or Transparency.TRANSLUCENT otherwise. The transfer type is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT that can hold a single pixel.- Parameters:
- bits- the number of bits in the pixel values; for example, the sum of the number of bits in the masks.
- rmask- specifies a mask indicating which bits in an integer pixel contain the red component
- gmask- specifies a mask indicating which bits in an integer pixel contain the green component
- bmask- specifies a mask indicating which bits in an integer pixel contain the blue component
- amask- specifies a mask indicating which bits in an integer pixel contain the alpha component
 
- 
DirectColorModelpublic DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType) Constructs aDirectColorModelfrom the specified parameters. Color components are in the specifiedColorSpace, which must be of type ColorSpace.TYPE_RGB and have minimum normalized component values which are all 0.0 and maximum values which are all 1.0. The masks specify which bits in anintpixel representation contain the red, green and blue color samples and the alpha sample, if present. Ifamaskis 0, pixel values do not contain alpha information and all pixels are treated as opaque, which means that alpha = 1.0. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of anintpixel representation. If there is alpha, thebooleanisAlphaPremultipliedspecifies how to interpret color and alpha samples in pixel values. If thebooleanistrue, color samples are assumed to have been multiplied by the alpha sample. The transparency value is Transparency.OPAQUE, if no alpha is present, or Transparency.TRANSLUCENT otherwise. The transfer type is the type of primitive array used to represent pixel values and must be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT.- Parameters:
- space- the specified- ColorSpace
- bits- the number of bits in the pixel values; for example, the sum of the number of bits in the masks.
- rmask- specifies a mask indicating which bits in an integer pixel contain the red component
- gmask- specifies a mask indicating which bits in an integer pixel contain the green component
- bmask- specifies a mask indicating which bits in an integer pixel contain the blue component
- amask- specifies a mask indicating which bits in an integer pixel contain the alpha component
- isAlphaPremultiplied-- trueif color samples are premultiplied by the alpha sample;- falseotherwise
- transferType- the type of array used to represent pixel values
- Throws:
- IllegalArgumentException- if- spaceis not a TYPE_RGB space or if the min/max normalized component values are not 0.0/1.0.
 
 
- 
- 
Method Details- 
getRedMaskpublic final int getRedMask()Returns the mask indicating which bits in anintpixel representation contain the red color component.- Returns:
- the mask, which indicates which bits of the intpixel representation contain the red color sample.
 
- 
getGreenMaskpublic final int getGreenMask()Returns the mask indicating which bits in anintpixel representation contain the green color component.- Returns:
- the mask, which indicates which bits of the intpixel representation contain the green color sample.
 
- 
getBlueMaskpublic final int getBlueMask()Returns the mask indicating which bits in anintpixel representation contain the blue color component.- Returns:
- the mask, which indicates which bits of the intpixel representation contain the blue color sample.
 
- 
getAlphaMaskpublic final int getAlphaMask()Returns the mask indicating which bits in anintpixel representation contain the alpha component.- Returns:
- the mask, which indicates which bits of the intpixel representation contain the alpha sample.
 
- 
getRedpublic final int getRed(int pixel) Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as anint. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the red value is 0.- Specified by:
- getRedin class- ColorModel
- Parameters:
- pixel- the specified pixel
- Returns:
- the red color component for the specified pixel, from
         0 to 255 in the sRGB ColorSpace.
 
- 
getGreenpublic final int getGreen(int pixel) Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as anint. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the green value is 0.- Specified by:
- getGreenin class- ColorModel
- Parameters:
- pixel- the specified pixel
- Returns:
- the green color component for the specified pixel, from
         0 to 255 in the sRGB ColorSpace.
 
- 
getBluepublic final int getBlue(int pixel) Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as anint. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the blue value is 0.- Specified by:
- getBluein class- ColorModel
- Parameters:
- pixel- the specified pixel
- Returns:
- the blue color component for the specified pixel, from
         0 to 255 in the sRGB ColorSpace.
 
- 
getAlphapublic final int getAlpha(int pixel) Returns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified as anint.- Specified by:
- getAlphain class- ColorModel
- Parameters:
- pixel- the specified pixel
- Returns:
- the value of the alpha component of pixelfrom 0 to 255.
 
- 
getRGBpublic final int getRGB(int pixel) Returns the color/alpha components of the pixel in the default RGB color model format. A color conversion is done if necessary. The pixel value is specified as anint. The returned value is in a non pre-multiplied format. Thus, if the alpha is premultiplied, this method divides it out of the color components. If the alpha value is 0, for example, the color values are each 0.- Overrides:
- getRGBin class- ColorModel
- Parameters:
- pixel- the specified pixel
- Returns:
- the RGB value of the color/alpha components of the specified pixel.
- See Also:
 
- 
getRedReturns the red color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the red value is 0. IfinDatais not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifinDatais not large enough to hold a pixel value for thisColorModel. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType. AnUnsupportedOperationExceptionis thrown if thistransferTypeis not supported by thisColorModel.- Overrides:
- getRedin class- ColorModel
- Parameters:
- inData- the array containing the pixel value
- Returns:
- the value of the red component of the specified pixel.
- Throws:
- ArrayIndexOutOfBoundsException- if- inDatais not large enough to hold a pixel value for this color model
- ClassCastException- if- inDatais not a primitive array of type- transferType
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
 
- 
getGreenReturns the green color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the green value is 0. IfinDatais not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifinDatais not large enough to hold a pixel value for thisColorModel. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType. AnUnsupportedOperationExceptionis thrown if thistransferTypeis not supported by thisColorModel.- Overrides:
- getGreenin class- ColorModel
- Parameters:
- inData- the array containing the pixel value
- Returns:
- the value of the green component of the specified pixel.
- Throws:
- ArrayIndexOutOfBoundsException- if- inDatais not large enough to hold a pixel value for this color model
- ClassCastException- if- inDatais not a primitive array of type- transferType
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
 
- 
getBlueReturns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGBColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. The returned value is a non pre-multiplied value. Thus, if the alpha is premultiplied, this method divides it out before returning the value. If the alpha value is 0, for example, the blue value is 0. IfinDatais not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifinDatais not large enough to hold a pixel value for thisColorModel. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType. AnUnsupportedOperationExceptionis thrown if thistransferTypeis not supported by thisColorModel.- Overrides:
- getBluein class- ColorModel
- Parameters:
- inData- the array containing the pixel value
- Returns:
- the value of the blue component of the specified pixel.
- Throws:
- ArrayIndexOutOfBoundsException- if- inDatais not large enough to hold a pixel value for this color model
- ClassCastException- if- inDatais not a primitive array of type- transferType
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
 
- 
getAlphaReturns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. IfinDatais not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifinDatais not large enough to hold a pixel value for thisColorModel. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType. If thistransferTypeis not supported, anUnsupportedOperationExceptionis thrown.- Overrides:
- getAlphain class- ColorModel
- Parameters:
- inData- the specified pixel
- Returns:
- the alpha component of the specified pixel, scaled from 0 to 255.
- Throws:
- ClassCastException- if- inDatais not a primitive array of type- transferType
- ArrayIndexOutOfBoundsException- if- inDatais not large enough to hold a pixel value for this- ColorModel
- UnsupportedOperationException- if this- tranferTypeis not supported by this- ColorModel
 
- 
getRGBReturns the color/alpha components for the specified pixel in the default RGB color model format. A color conversion is done if necessary. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. IfinDatais not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifinDatais not large enough to hold a pixel value for thisColorModel. The returned value is in a non pre-multiplied format. Thus, if the alpha is premultiplied, this method divides it out of the color components. If the alpha value is 0, for example, the color values is 0. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType.- Overrides:
- getRGBin class- ColorModel
- Parameters:
- inData- the specified pixel
- Returns:
- the color and alpha components of the specified pixel.
- Throws:
- UnsupportedOperationException- if this- transferTypeis not supported by this- ColorModel
- See Also:
 
- 
getDataElementsReturns a data element array representation of a pixel in thisColorModel, given an integer pixel representation in the default RGB color model. This array can then be passed to thesetDataElementsmethod of aWritableRasterobject. If the pixel variable isnull, a new array is allocated. Ifpixelis notnull, it must be a primitive array of typetransferType; otherwise, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifpixelis not large enough to hold a pixel value for thisColorModel. The pixel array is returned. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType.- Overrides:
- getDataElementsin class- ColorModel
- Parameters:
- rgb- the integer pixel representation in the default RGB color model
- pixel- the specified pixel
- Returns:
- an array representation of the specified pixel in this
         ColorModel
- Throws:
- ClassCastException- if- pixelis not a primitive array of type- transferType
- ArrayIndexOutOfBoundsException- if- pixelis not large enough to hold a pixel value for this- ColorModel
- UnsupportedOperationException- if this- transferTypeis not supported by this- ColorModel
- See Also:
 
- 
getComponentspublic final int[] getComponents(int pixel, int[] components, int offset) Returns an array of unnormalized color/alpha components given a pixel in thisColorModel. The pixel value is specified as anint. If thecomponentsarray isnull, a new array is allocated. Thecomponentsarray is returned. Color/alpha components are stored in thecomponentsarray starting atoffset, even if the array is allocated by this method. AnArrayIndexOutOfBoundsExceptionis thrown if thecomponentsarray is notnulland is not large enough to hold all the color and alpha components, starting atoffset.- Overrides:
- getComponentsin class- ColorModel
- Parameters:
- pixel- the specified pixel
- components- the array to receive the color and alpha components of the specified pixel
- offset- the offset into the- componentsarray at which to start storing the color and alpha components
- Returns:
- an array containing the color and alpha components of the specified pixel starting at the specified offset.
 
- 
getComponentsReturns an array of unnormalized color/alpha components given a pixel in thisColorModel. The pixel value is specified by an array of data elements of typetransferTypepassed in as an object reference. Ifpixelis not a primitive array of typetransferType, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifpixelis not large enough to hold a pixel value for thisColorModel. If thecomponentsarray isnull, a new array is allocated. Thecomponentsarray is returned. Color/alpha components are stored in thecomponentsarray starting atoffset, even if the array is allocated by this method. AnArrayIndexOutOfBoundsExceptionis thrown if thecomponentsarray is notnulland is not large enough to hold all the color and alpha components, starting atoffset. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType.- Overrides:
- getComponentsin class- ColorModel
- Parameters:
- pixel- the specified pixel
- components- the array to receive the color and alpha components of the specified pixel
- offset- the offset into the- componentsarray at which to start storing the color and alpha components
- Returns:
- an array containing the color and alpha components of the specified pixel starting at the specified offset.
- Throws:
- ClassCastException- if- pixelis not a primitive array of type- transferType
- ArrayIndexOutOfBoundsException- if- pixelis not large enough to hold a pixel value for this- ColorModel, or if- componentsis not- nulland is not large enough to hold all the color and alpha components, starting at- offset
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
 
- 
createCompatibleWritableRasterCreates aWritableRasterwith the specified width and height that has a data layout (SampleModel) compatible with thisColorModel.- Overrides:
- createCompatibleWritableRasterin class- ColorModel
- Parameters:
- w- the width to apply to the new- WritableRaster
- h- the height to apply to the new- WritableRaster
- Returns:
- a WritableRasterobject with the specified width and height.
- Throws:
- IllegalArgumentException- if- wor- his less than or equal to zero
- See Also:
 
- 
getDataElementpublic int getDataElement(int[] components, int offset) Returns a pixel value represented as anintin thisColorModel, given an array of unnormalized color/alpha components. AnArrayIndexOutOfBoundsExceptionis thrown if thecomponentsarray is not large enough to hold all the color and alpha components, starting atoffset.- Overrides:
- getDataElementin class- ColorModel
- Parameters:
- components- an array of unnormalized color and alpha components
- offset- the index into- componentsat which to begin retrieving the color and alpha components
- Returns:
- an intpixel value in thisColorModelcorresponding to the specified components.
- Throws:
- ArrayIndexOutOfBoundsException- if the- componentsarray is not large enough to hold all of the color and alpha components starting at- offset
 
- 
getDataElementsReturns a data element array representation of a pixel in thisColorModel, given an array of unnormalized color/alpha components. This array can then be passed to thesetDataElementsmethod of aWritableRasterobject. AnArrayIndexOutOfBoundsExceptionis thrown if thecomponentsarray is not large enough to hold all the color and alpha components, starting at offset. If theobjvariable isnull, a new array is allocated. Ifobjis notnull, it must be a primitive array of typetransferType; otherwise, aClassCastExceptionis thrown. AnArrayIndexOutOfBoundsExceptionis thrown ifobjis not large enough to hold a pixel value for thisColorModel. SinceDirectColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType.- Overrides:
- getDataElementsin class- ColorModel
- Parameters:
- components- an array of unnormalized color and alpha components
- offset- the index into- componentsat which to begin retrieving color and alpha components
- obj- the- Objectrepresenting an array of color and alpha components
- Returns:
- an Objectrepresenting an array of color and alpha components.
- Throws:
- ClassCastException- if- objis not a primitive array of type- transferType
- ArrayIndexOutOfBoundsException- if- objis not large enough to hold a pixel value for this- ColorModelor the- componentsarray is not large enough to hold all of the color and alpha components starting at- offset
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
- See Also:
 
- 
coerceDataForces the raster data to match the state specified in theisAlphaPremultipliedvariable, assuming the data is currently correctly described by thisColorModel. 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 thisColorModelwith theisAlphaPremultipliedflag set appropriately. This method will throw aUnsupportedOperationExceptionif this transferType is not supported by thisColorModel. SinceColorModelcan be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupported transferType.- Overrides:
- coerceDatain class- ColorModel
- Parameters:
- raster- the- WritableRasterdata
- isAlphaPremultiplied-- trueif the alpha is premultiplied;- falseotherwise
- Returns:
- a ColorModelobject that represents the coerced data.
- Throws:
- UnsupportedOperationException- if this- transferTypeis not supported by this color model
 
- 
isCompatibleRasterReturnstrueifrasteris compatible with thisColorModelandfalseif it is not.- Overrides:
- isCompatibleRasterin class- ColorModel
- Parameters:
- raster- the- Rasterobject to test for compatibility
- Returns:
- trueif- rasteris compatible with this- ColorModel;- falseotherwise.
 
- 
toStringReturns aStringthat represents thisDirectColorModel.- Overrides:
- toStringin class- ColorModel
- Returns:
- a Stringrepresenting thisDirectColorModel.
 
 
-