diff options
Diffstat (limited to 'libjava/java/awt/image/ColorModel.java')
-rw-r--r-- | libjava/java/awt/image/ColorModel.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java index 14a1b2e73b9..fab51667edb 100644 --- a/libjava/java/awt/image/ColorModel.java +++ b/libjava/java/awt/image/ColorModel.java @@ -120,10 +120,32 @@ public abstract class ColorModel implements Transparency Buffers.smallestAppropriateTransferType(bits * 4)); } + /** + * Constructs a ColorModel that translates pixel values to + * color/alpha components. + * + * @exception IllegalArgumentException If the length of the bit array is less + * than the number of color or alpha components in this ColorModel, or if the + * transparency is not a valid value, or if the sum of the number of bits in + * bits is less than 1 or if any of the elements in bits is less than 0. + */ protected ColorModel(int pixel_bits, int[] bits, ColorSpace cspace, boolean hasAlpha, boolean isAlphaPremultiplied, int transparency, int transferType) { + int bits_sum = 0; + for (int i = 0; i < bits.length; i++) + { + if (bits [i] < 0) + throw new IllegalArgumentException (); + + bits_sum |= bits [i]; + } + + if ((bits.length < cspace.numComponents) + || (bits_sum < 1)) + throw new IllegalArgumentException (); + this.pixel_bits = pixel_bits; this.bits = bits; this.cspace = cspace; |