United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6424528 : Wrong mapping of color happens if one takes print of a swing component in 16 bit color depth

Details
Type:
Bug
Submit Date:
2006-05-11
Status:
Resolved
Updated Date:
2010-12-09
Project Name:
JDK
Resolved Date:
2006-06-26
Component:
client-libs
OS:
windows_nt,linux,generic,windows_xp,windows_2000
Sub-Component:
2d
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.0,1.4.2,1.4.2_05,1.4.2_10,6
Fixed Versions:
1.4.2_13 (b01)

Related Reports
Backport:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
There is an issue in 1.4.2_10 that if one takes the printout of the Swing component with color depth of 16 bit, incorrect mapping of color happens in the printout.  This issue happens on Windows 2000 / XP platform.

Please refer attached GUI testcase and try to take printout.  Please make sure to change screen to 16 bit at Desktop -> Properties -> Settings (TAB) -> Colors and apply it before taking printout.

Please note that this is generic Java 2D issue and has nothing to with kind of printer used.

                                    

Comments
EVALUATION

This is a known issue with Swing and that's due to Java2D issue described in CR 4886732.
                                     
2006-05-11
WORK AROUND

Swing component by default uses double buffering and that ends up running into this issue. 
Switching off double buffering can work around this issue.  Double buffering can be disabled by use of javax.swing.RepaintManager.setDoubleBufferingEnabled(false) before making a call to Component.paint(Graphics) in print method.
54a55,56
>                                       RepaintManager rm = RepaintManager.currentManager(panel);
>                                       rm.setDoubleBufferingEnabled(false);
55a58
>                                       rm.setDoubleBufferingEnabled(true);
                                     
2006-05-11
SUGGESTED FIX

AffineTransform is used to scale and tranform buffered image to printer context. Fix is to getting around the problem by rounding the co-ordinates close to an integral to avoid fp error which then results in selecting optimal image transform pipe.
                                     
2006-05-11



Hardware and Software, Engineered to Work Together