I’ve been doing some work with multiresolution images and I’m coming to the 
conclusion that there is a missing concept: a nominal size.

The nominal size of an image may be needed for layout. For rendering, the 
nominal size combined with the display resolution determines the size of 
rendered image.

I think there is an assumption that the base image (a concept defined by 
AbstractMultiResolutionImage) size is the nominal image size.

The documentation of getBaseImage() does not actually support that assumption.

It says:

"Return the base image representing the best version of the image for rendering 
at the default width and height.”

Unfortunately, it refers to a default width and height, which does not exist.

All of this stems from an implementation-oriented perspective that made sense 
years ago, but no longer does.

As almost all displays are HiDPI, it should not be a requirement to have a 1x 
representation, as the normal scaling performed by the graphics context can 
produce one if needed.

More importantly, there is a missing concept: the ability to change the nominal 
size. Suppose I have a 128x128 pixel image and I want to use it as an icon of 
size 32x32. I don’t really want to scale the image to 32x32, because that loses 
the extra resolution and the icon will look fuzzy on most displays. What I want 
to do is create a variant of the multiresolution image with a nominal size of 
32x32.

One might expect getScaledInstance to do that. The documentation basically says 
that:

Creates a scaled version of this image.
     * A new {@code Image} object is returned which will render
     * the image at the specified {@code width} and
     * {@code height} by default. 

I like the definition, but not the code. MultiResolutionCachedImage instead 
returns one of the variant images, and all the others create a new image at the 
specified size. This is not what one wants for a HiDPI display.

I suspect that NSImage in macOS was a model for Java’s multiresolution image 
support. NSImage explicitly supports a nominal size distinct from the image 
representations. Somehow, that idea got lost in translation.


Reply via email to