public PackedColorModel(ColorSpace space,
int bits,
int[] colorMaskArray,
int alphaMask,
boolean isAlphaPremultiplied,
int trans,
int transferType) {
super(bits, PackedColorModel.createBitsArray(colorMaskArray,
alphaMask),
space, (alphaMask == 0 ? false : true),
isAlphaPremultiplied, trans, transferType);
if (bits < 1 || bits > 32) {
throw new IllegalArgumentException("Number of bits must be between"
+" 1 and 32.");
}
maskArray = new int[numComponents];
maskOffsets = new int[numComponents];
scaleFactors = new float[numComponents];
for (int i=0; i < numColorComponents; i++) {
// Get the mask offset and #bits
DecomposeMask(colorMaskArray[i], i, space.getName(i));
}
if (alphaMask != 0) {
DecomposeMask(alphaMask, numColorComponents, "alpha");
if (nBits[numComponents-1] == 1) {
transparency = Transparency.BITMASK;
}
}
}
Constructs a PackedColorModel from a color mask array,
which specifies which bits in an int pixel representation
contain each of the color samples, and an alpha mask. Color
components are in the specified ColorSpace. The length of
colorMaskArray should be the number of components in
the ColorSpace. All of the bits in each mask
must be contiguous and fit in the specified number of least significant
bits of an int pixel representation. If the
alphaMask is 0, there is no alpha. If there is alpha,
the boolean isAlphaPremultiplied specifies
how to interpret color and alpha samples in pixel values. If the
boolean is true, color samples are assumed
to have been multiplied by the alpha sample. The transparency,
trans, specifies what alpha values can be represented
by this color model. The transfer type is the type of primitive
array used to represent pixel values. Parameters:
space - the specified ColorSpace
bits - the number of bits in the pixel values
colorMaskArray - array that specifies the masks representing
the bits of the pixel values that represent the color
components
alphaMask - specifies the mask representing
the bits of the pixel values that represent the alpha
component
isAlphaPremultiplied - true if color samples are
premultiplied by the alpha sample; false otherwise
trans - specifies the alpha value that can be represented by
this color model
transferType - the type of array used to represent pixel values
Throws:
IllegalArgumentException - if bits is less than
1 or greater than 32
|
public PackedColorModel(ColorSpace space,
int bits,
int rmask,
int gmask,
int bmask,
int amask,
boolean isAlphaPremultiplied,
int trans,
int transferType) {
super (bits, PackedColorModel.createBitsArray(rmask, gmask, bmask,
amask),
space, (amask == 0 ? false : true),
isAlphaPremultiplied, trans, transferType);
if (space.getType() != ColorSpace.TYPE_RGB) {
throw new IllegalArgumentException("ColorSpace must be TYPE_RGB.");
}
maskArray = new int[numComponents];
maskOffsets = new int[numComponents];
scaleFactors = new float[numComponents];
DecomposeMask(rmask, 0, "red");
DecomposeMask(gmask, 1, "green");
DecomposeMask(bmask, 2, "blue");
if (amask != 0) {
DecomposeMask(amask, 3, "alpha");
if (nBits[3] == 1) {
transparency = Transparency.BITMASK;
}
}
}
Constructs a PackedColorModel from the specified
masks which indicate which bits in an int pixel
representation contain the alpha, red, green and blue color samples.
Color components are in the specified ColorSpace, which
must be of type ColorSpace.TYPE_RGB. All of the bits in each
mask must be contiguous and fit in the specified number of
least significant bits of an int pixel representation. If
amask is 0, there is no alpha. If there is alpha,
the boolean isAlphaPremultiplied
specifies how to interpret color and alpha samples
in pixel values. If the boolean is true,
color samples are assumed to have been multiplied by the alpha sample.
The transparency, trans, specifies what alpha values
can be represented by this color model.
The transfer type is the type of primitive array used to represent
pixel values. Parameters:
space - the specified ColorSpace
bits - the number of bits in the pixel values
rmask - specifies the mask representing
the bits of the pixel values that represent the red
color component
gmask - specifies the mask representing
the bits of the pixel values that represent the green
color component
bmask - specifies the mask representing
the bits of the pixel values that represent
the blue color component
amask - specifies the mask representing
the bits of the pixel values that represent
the alpha component
isAlphaPremultiplied - true if color samples are
premultiplied by the alpha sample; false otherwise
trans - specifies the alpha value that can be represented by
this color model
transferType - the type of array used to represent pixel values
Throws:
IllegalArgumentException - if space is not a
TYPE_RGB space
Also see:
- ColorSpace
|