Maptool: Portrait image rendering is not scaled with sufficient quality

Created on 27 Apr 2020  路  19Comments  路  Source: RPTools/maptool

Describe the bug

Various places in MapTool set or don't set the rendering hint for interpolation. The PointerTool painting the portrait for example sets no hint, resulting in a badly scaled image. The Handout (AssetViewer) does set Bilinear (only applies when picture is larger than screen size).

Also considered : the Token rendering itself (ZoneRenderer) is done without appropriate hint (right side, left side with patched in rendering hint)

image

The ImagePanel has a switch - shrink with bilinear, grow with bicubic as of #691

          if (dim.width < image.getWidth(null) || dim.height < image.getHeight(null)) {
            g.setRenderingHint(
                RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
          } else if (dim.width > image.getWidth(null) || dim.height > image.getHeight(null)) {
            g.setRenderingHint(
                RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          }

To Reproduce

Look at rendered images.

Expected behavior

Use bilinear everywhere consistently, not sure bicubic is worth it anywhere.

MapTool Info

  • Version: 1.6.1/develop

Desktop (please complete the following information):

  • OS: Windows

Additional context

SwingUtil has a common antialiasing method/pattern, that should probably be used everywhere. Maybe it should just set up antialiasing and interpolation hint to 'pretty'. There are some spots in code that explicitly turn off antialiasing (sharp lines needed).

bug tested

Most helpful comment

image

background image - top, as per branch develop, bottom, if I set hint to cubic

All 19 comments

Is there a performance issue? There could be an option for rendering -

FAST (no antialising, no interpolation)
NORMAL (antialiasing, bilinear interpolation)
QUALITY (antialiasing, bicubic interpolation)

I appreciate your effort to improve the image rendering in MapTool. I for one has been disappointing of how scaled images look.

However, I find your example troubling. The image on the right looks terrible to me, and much worse than the one on the left. Some of the text is near unreadable, and the edges of the characters look jagged. I really don't want MapTool to look like that.

Indeed. That right side image is really terrible.

As we will be moving to Java 14 in the very near future there may be other rendering options available or there may be other improvements that will help.

Most of the decisions about the scaling inside of MapTool happened a long time ago and performance was certainly a concern at the time.

oops, sorry, I mixed up left and right, the left is the one that I've patched

image

background image - top, as per branch develop, bottom, if I set hint to cubic

From some tests I did, I believe the zone renderer currently uses VALUE_INTERPOLATION_NEAREST_NEIGHBOR.

I tried switching it to VALUE_INTERPOLATION_BILINEAR and got a very noticable improvement in quality when downsampling high quality images.

Also, I found some options for resizing images in Java:

https://stackoverflow.com/questions/24745147/java-resize-image-without-losing-quality

I'm sure lots of people have done studies/analysis trying to figure out the best approach for a given situation. Might as well take advantage of that. I'm off to read the SO link...

The ZoneRenderer doesn't use a scaling hint right now - we tried that but the difference was not THAT visible and rendering speed decreased.

VALUE_INTERPOLATION_BILINEAR Is used in
AssetViewer
ImagePanel
Saving of Token
Overlay (Portrait)

Overall I found the improved quality when scaling a token to be not significant enough.

@Merudo do you have a screenshot? I'm still wondering if background images should at least be scaled with a hint. Ultimately we'll need an option to turn on/off high quality rendering to not lock out slow machines.

When you inspected the images for quality, which scaling did you choose?

In my tests, the difference was very pronounced at about 50-80% scaling.

And yes, I agree the user should be in control for this. We could easily let the user select between nearest neighbor, bi-linear and bi-cubic. Most videogames have tons of settings related to graphics (texture quality, anti-aliasing, VSync, tessellation, occlusion, anisotropic filtering, HDR, shadows, etc.), I don't think us having a single interpolation setting would be too much.

Especially since in my experience, in VTT around 50% of movement is zooming in and out :)

The link to your now defunct commit related to the zone renderer: https://github.com/nmeier/maptool/commit/7ef77f91ab4793a4c2e7c96175248e12d106f9c7

img1
img2

At 60% scaling, comparing bilinear (first image) to nearest neighbor (second image).

The difference is especially pronounced for the small text for the town names - one of the most important information on the map.

This one is at 75% scaling:

img3
img4

Yea, that top one is definitely more readable.

I'm not opposed to adding a Graphics? Video? Performance? section (tab?) for 1.8 and add some options. I don't think there is a UI option (just /command?) for Craigs noise filter thing either which could be added?

Some final images:

dude1
dude2

The right side of the coat looks pretty bad in the second one.

Yea, that top one is definitely more readable.

I'm not opposed to adding a Graphics? Video? Performance? section (tab?) for 1.8 and add some options. I don't think there is a UI option (just /command?) for Craigs noise filter thing either which could be added?

Though it's a sidenote, the noise should go in the existing accessibility tab (imo)

Such a high quality background image works well, yes. Question for me was whether the performance hit is ok for pattern images. And tokens themselves seemed not significantly better without pixel peeping.
Agree on the settings - that made me focus on the overlay/portrait only as that's something you want to show and be able to read. It's rendered once only, so no significant performance hit to speak off.

There should be an issue for a real rendering hint/quality of rendering setting, yes.

A new issue to add a rendering quality selection to the Application -> Performance preferences for selecting interpolation method and the noise filter settings to Accessibility -> Visual(?) would be a good idea.

The quality improvement doesn't justify the 10x performance hit for bicubic and the 2x hit for bilinear for me but those with gaming rigs I'm guessing won't be impacted.

Tested. Portrait rendering improved. No adverse side effects observed.

Yea, that top one is definitely more readable.
I'm not opposed to adding a Graphics? Video? Performance? section (tab?) for 1.8 and add some options. I don't think there is a UI option (just /command?) for Craigs noise filter thing either which could be added?

Though it's a sidenote, the noise should go in the existing accessibility tab (imo)

Fair enough and good point. I think there is also a Performance section with just 2 options. Maybe an assessment of what goes where is needed. A little housecleaning. It's easy enough to move those things around in the same dialog.

Was this page helpful?
0 / 5 - 0 ratings