7014528: ColorModel and SampleModel gotten from the same ImageTypeSpecifier instance can be not compatible
authorbae
Thu, 17 Mar 2011 17:45:01 +0300
changeset 8750 50fec4bad1f7
parent 8749 ab0c8dca6d47
child 8751 f317a5eb26da
7014528: ColorModel and SampleModel gotten from the same ImageTypeSpecifier instance can be not compatible Reviewed-by: jgodinez, prr
jdk/src/share/classes/java/awt/image/PackedColorModel.java
--- a/jdk/src/share/classes/java/awt/image/PackedColorModel.java	Wed Mar 16 19:21:06 2011 +0300
+++ b/jdk/src/share/classes/java/awt/image/PackedColorModel.java	Thu Mar 17 17:45:01 2011 +0300
@@ -343,8 +343,13 @@
         if (bitMasks.length != maskArray.length) {
             return false;
         }
+
+        /* compare 'effective' masks only, i.e. only part of the mask
+         * which fits the capacity of the transfer type.
+         */
+        int maxMask = (int)((1L << DataBuffer.getDataTypeSize(transferType)) - 1);
         for (int i=0; i < bitMasks.length; i++) {
-            if (bitMasks[i] != maskArray[i]) {
+            if ((maxMask & bitMasks[i]) != (maxMask & maskArray[i])) {
                 return false;
             }
         }