-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
generic
-
generic
Name: krT82822 Date: 06/22/99
[note: reclassified as AWT vs. 2D, since this code is in the image subtree, not geom.
also changed version to 1.2.2, vs. original 1.2, since source code cited is identical in 1.2.2, as far as I can tell --kevin.ryan@eng, 6/22/99]
I have not included source code because this would only complicate
the bug report and because the bug can be easily reproduced with
a pocket calculator.
1. The method 'getDataElements' of class 'DirectColorModel' does not round to the correct values
2. Assume we have a 5/6/5 DirectColorModel.
the PackedColorModel superclass now has as value for 'scaleFactor[]'
line 231: scaleFactors[idx] = 255. /((1 << count) - 1);
in case of red and blue component (5 bit): 255. / 31.
in case of green component (6 bit): 255. / 63.
This is still correct
3. Assume we call 'getDataElements(0xFFFFFF/*white*/,null)'
see the 'DirectColorModel' source code :
521: intpixel[0] = 0;
522: for (i=0; i < nbands; i++) {
523: c = (int)(((rgb>>shifts[i])&0xff)*normAlpha/scaleFactors[i]);
524: intpixel[0] |= (c << maskOffsets[i]) & maskArray[i];
525: }
for the red and blue component :
523: c = (int)(255*1.0/(255.0/31.0))
523: c = (int) (255*1.0/(255./31.)
523: c = (int) (30.999999999999996)
523: c = 30 instead of 31
The result of the method call is '0xF7FE' instead of '0xFFFF'.
This result is clearly visible on printers.
Why not make c = (int) Math.round(...) ?
(Review ID: 84648)
======================================================================
- duplicates
-
JDK-4412670 JCK: api/java_awt/java2d/image/ComponentColorModel/index.html#GetDataElementsTes
-
- Closed
-