summaryrefslogtreecommitdiffstats
path: root/libjava/java/awt/image
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/awt/image')
-rw-r--r--libjava/java/awt/image/ColorModel.java22
-rw-r--r--libjava/java/awt/image/ImageFilter.java13
2 files changed, 33 insertions, 2 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;
diff --git a/libjava/java/awt/image/ImageFilter.java b/libjava/java/awt/image/ImageFilter.java
index b34bb7d9cd3..86bc0210a4b 100644
--- a/libjava/java/awt/image/ImageFilter.java
+++ b/libjava/java/awt/image/ImageFilter.java
@@ -81,9 +81,18 @@ public class ImageFilter implements ImageConsumer, Cloneable
*
* @see java.lang.Object#clone ()
*/
- public Object clone() throws CloneNotSupportedException
+ public Object clone()
{
- return (super.clone());
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // This should never happen as this class implements the
+ // Cloneable interface.
+ throw new InternalError ();
+ }
}
/**
OpenPOWER on IntegriCloud