120 |
Buffers.smallestAppropriateTransferType(bits * 4)); |
Buffers.smallestAppropriateTransferType(bits * 4)); |
121 |
} |
} |
122 |
|
|
123 |
|
/** |
124 |
|
* Constructs a ColorModel that translates pixel values to |
125 |
|
* color/alpha components. |
126 |
|
* |
127 |
|
* @exception IllegalArgumentException If the length of the bit array is less |
128 |
|
* than the number of color or alpha components in this ColorModel, or if the |
129 |
|
* transparency is not a valid value, or if the sum of the number of bits in |
130 |
|
* bits is less than 1 or if any of the elements in bits is less than 0. |
131 |
|
*/ |
132 |
protected ColorModel(int pixel_bits, int[] bits, ColorSpace cspace, |
protected ColorModel(int pixel_bits, int[] bits, ColorSpace cspace, |
133 |
boolean hasAlpha, boolean isAlphaPremultiplied, |
boolean hasAlpha, boolean isAlphaPremultiplied, |
134 |
int transparency, int transferType) |
int transparency, int transferType) |
135 |
{ |
{ |
136 |
|
int bits_sum = 0; |
137 |
|
for (int i = 0; i < bits.length; i++) |
138 |
|
{ |
139 |
|
if (bits [i] < 0) |
140 |
|
throw new IllegalArgumentException (); |
141 |
|
|
142 |
|
bits_sum |= bits [i]; |
143 |
|
} |
144 |
|
|
145 |
|
if ((bits.length < cspace.numComponents) |
146 |
|
|| (bits_sum < 1)) |
147 |
|
throw new IllegalArgumentException (); |
148 |
|
|
149 |
this.pixel_bits = pixel_bits; |
this.pixel_bits = pixel_bits; |
150 |
this.bits = bits; |
this.bits = bits; |
151 |
this.cspace = cspace; |
this.cspace = cspace; |