Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289707

Use LookupIconIdFromDirectoryEx to extract only available sizes of icon

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 17, 18, 19, 20
    • client-libs
    • None

      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

            Unassigned Unassigned
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: