JDK-8289707 : Use LookupIconIdFromDirectoryEx to extract only available sizes of icon
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 17,18,19,20
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-07-04
  • Updated: 2022-07-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
During the initial implementation of JDK-8182043, the approach of using LookupIconIdFromDirectoryEx [1][2] was discussed [3][4]. But it didn't work well [5], and thus it was abandoned.

This may not work in all the cases because to use this method we have to know the location of the icon resource and its id.

Yet with this approach, we won't request icons which don't exist. Currently, a predefined set of icon sizes is fetched [6]; the icons which don't exist are upscaled/downscaled by Windows.

On the other hand, the way Window stretches the icon may produce a better result than what is used by default in Java, see JDK-8282526 which describes a situation where downscaling an icon loses details.

This needs investigation. The complexity of using this API could be not worth it.


References:
[1] https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-lookupiconidfromdirectoryex
[2] https://devblogs.microsoft.com/oldnewthing/20120720-00/?p=7083
[3] https://mail.openjdk.org/pipermail/awt-dev/2020-May/015924.html
[4] https://mail.openjdk.org/pipermail/awt-dev/2020-August/016074.html
[5] https://mail.openjdk.org/pipermail/awt-dev/2020-August/016076.html
[6] https://github.com/openjdk/jdk/blob/7f52c50ba32eecf5f379f8db30ac6a5cc50b3b66/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L90

Other references to discussions:
https://github.com/openjdk/jdk/pull/380#issuecomment-702999573
https://github.com/openjdk/jdk/pull/380#issuecomment-704590746
https://github.com/openjdk/jdk/pull/7805#discussion_r893306463