United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7148275 [macosx] setIconImages() not working correctly (distorted icon when minimized)
JDK-7148275 : [macosx] setIconImages() not working correctly (distorted icon when minimized)

Details
Type:
Bug
Submit Date:
2012-02-23
Status:
Closed
Updated Date:
2012-04-10
Project Name:
JDK
Resolved Date:
2012-04-05
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u4
Fixed Versions:
7u4 (b18)

Related Reports
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
https://www.netbeans.org/bugzilla/show_bug.cgi?id=208744

NetBeans icon, when the running application is minimized into Mac's panel, is distorted into low resolution as can be seen in the screenshot at

http://bugzilla-attachments-208744.netbeans.org/bugzilla/attachment.cgi?id=116017

NetBeans is using -Xdock:icon=$progdir/../nb/netbeans.icns startup parameter which works correctly with previous versions of Java on Mac. With 7u4 the provided icon is not used correctly by Java.

                                    
                                
https://www.netbeans.org/bugzilla/show_bug.cgi?id=208744

NetBeans icon, when the running application is minimized into Mac's panel, is distorted into low resolution as can be seen in the screenshot at

http://bugzilla-attachments-208744.netbeans.org/bugzilla/attachment.cgi?id=116017

NetBeans is using -Xdock:icon=$progdir/../nb/netbeans.icns startup parameter which works correctly with previous versions of Java on Mac. With 7u4 the provided icon is not used correctly by Java.

                                    

Comments
EVALUATION

The problem is reproducible. Note that even with Apple JDK the minimized icon is slightly worse in quality comparing to the running app icon. However, with Oracle JDK 7u4 the minimized icon looks very low-quality.
                                     
2012-02-27
SUGGESTED FIX

--- old/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2012-03-08 20:14:57.000000000 +0400
+++ new/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2012-03-08 20:14:56.000000000 +0400
@@ -725,9 +725,17 @@
             return null;
         }
 
-        // TODO: need a walk-through to find the best image.
-        // The best mean with higher resolution. Otherwise an icon looks bad.
-        final Image image = icons.get(0);
+        // Choose the best (largest) image
+        Image image = icons.get(0);
+        // Assume images are square, so check their widths only
+        int width = image.getWidth(null);
+        for (Image img : icons) {
+            final int w = img.getWidth(null);
+            if (w > width) {
+                image = img;
+                width = w;
+            }
+        }
         return CImage.getCreator().createFromImage(image);
     }
                                     
2012-03-08
EVALUATION

-Xdock:icon has nothing to do with the representation of minimized windows in the dock. The icon for a minimized window is specified with the Window.setIconImages() API.
                                     
2012-03-08
EVALUATION

CPlatformWindow.getImageForTarget() must walk through images to choose the largest one.
                                     
2012-03-08
EVALUATION

The problem is reproducible. Note that even with Apple JDK the minimized icon is slightly worse in quality comparing to the running app icon. However, with Oracle JDK 7u4 the minimized icon looks very low-quality.
                                     
2012-02-27
EVALUATION

-Xdock:icon has nothing to do with the representation of minimized windows in the dock. The icon for a minimized window is specified with the Window.setIconImages() API.
                                     
2012-03-08
EVALUATION

CPlatformWindow.getImageForTarget() must walk through images to choose the largest one.
                                     
2012-03-08
SUGGESTED FIX

--- old/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2012-03-08 20:14:57.000000000 +0400
+++ new/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2012-03-08 20:14:56.000000000 +0400
@@ -725,9 +725,17 @@
             return null;
         }
 
-        // TODO: need a walk-through to find the best image.
-        // The best mean with higher resolution. Otherwise an icon looks bad.
-        final Image image = icons.get(0);
+        // Choose the best (largest) image
+        Image image = icons.get(0);
+        // Assume images are square, so check their widths only
+        int width = image.getWidth(null);
+        for (Image img : icons) {
+            final int w = img.getWidth(null);
+            if (w > width) {
+                image = img;
+                width = w;
+            }
+        }
         return CImage.getCreator().createFromImage(image);
     }
                                     
2012-03-08



Hardware and Software, Engineered to Work Together