<AWT Dev> RFR: 8182043: Access to Windows Large Icons [v15]

Sergey Bylokhov serb at openjdk.java.net
Fri May 28 00:50:17 UTC 2021


On Thu, 27 May 2021 16:38:02 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> Is this requirement is so important? can we return an MRI(same as on Windows) which will have just one resolution? Otherwise what the user should do if the requested size was 32x32 but returned image will be 21x21? Paint the small icon or rescale it by the application?
>
>> Is this requirement is so important? can we return an MRI(same as on Windows) which will have just one resolution?
> 
> We might - when the implementation will be done on other platforms. Probably it will be done by me, probably - by someone else. Right now we return whatever we have so on Linux it is UIManager default icons for file or a folder (which is exactly what any file manager on Linux shows for any file and this is exactly what we promised in the method description). In the future it can change but for now it is all we can guarantee.

This is my point I think we should update this implementation to always return MRI of the requested size, otherwise, the code example of this will look like this:

    Icon icon = fsv.getSystemIcon(file, width, height);
    if (icon.getIconWidth() != width && icon.getIconHeight() != height) {
        return scaleTheIconInTheSameWayAsBeforeTheFix(icon, width, height);
    } else if (icon instanceof ImageIcon) {
        ImageIcon imageIcon = (ImageIcon) icon;
        if (icon.getImage() instanceof MultiResolutionImage) {
            MultiResolutionImage mri = (MultiResolutionImage) icon.getImage();
            return  mri.getResolutionVariant(width, height);
        } else {
            return imageIcon;
        }
    } else {
        return icon;
    }

I pretty sure we can do better than the code above.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2875


More information about the awt-dev mailing list