Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portrait image rendering is not scaled with sufficient quality #1709

Closed
nmeier opened this issue Apr 27, 2020 · 19 comments
Closed

Portrait image rendering is not scaled with sufficient quality #1709

nmeier opened this issue Apr 27, 2020 · 19 comments
Assignees
Labels
bug tested This issue has been QA tested by someone other than the developer.

Comments

@nmeier
Copy link
Contributor

nmeier commented Apr 27, 2020

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).

@nmeier
Copy link
Contributor Author

nmeier commented Apr 27, 2020

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)

@Merudo
Copy link
Member

Merudo commented Apr 27, 2020

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.

@Phergus Phergus added the bug label Apr 27, 2020
@Phergus
Copy link
Contributor

Phergus commented Apr 27, 2020

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.

@nmeier
Copy link
Contributor Author

nmeier commented Apr 27, 2020

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

@nmeier
Copy link
Contributor Author

nmeier commented Apr 27, 2020

image

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

nmeier added a commit to nmeier/maptool that referenced this issue Apr 27, 2020
…ing when zoomed, also for Portrait image rendered alongside stat sheet.

Quick fix only, doesn't address any of the spread out rendering hint logic.

Fixes RPTools#1709
nmeier added a commit to nmeier/maptool that referenced this issue Apr 30, 2020
…Since the portrait is scaled this leads to a better looking picture - same as asset viewer.

Fixes RPTools#1709
@nmeier nmeier changed the title Image rendering is inconsistent, either fast rendering, bilinear or bicubic Portrait image rendering is not scaled with sufficient quality Apr 30, 2020
@Merudo
Copy link
Member

Merudo commented May 15, 2020

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

@Azhrei
Copy link
Member

Azhrei commented May 15, 2020

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...

@nmeier
Copy link
Contributor Author

nmeier commented May 15, 2020

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.

@Merudo
Copy link
Member

Merudo commented May 15, 2020

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 :)

@Merudo
Copy link
Member

Merudo commented May 15, 2020

The link to your now defunct commit related to the zone renderer: nmeier@7ef77f9

@Merudo
Copy link
Member

Merudo commented May 15, 2020

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.

@Merudo
Copy link
Member

Merudo commented May 15, 2020

This one is at 75% scaling:

img3
img4

@JamzTheMan
Copy link
Member

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?

@Merudo
Copy link
Member

Merudo commented May 15, 2020

Some final images:

dude1
dude2

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

@melek
Copy link
Collaborator

melek commented May 15, 2020

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)

@nmeier
Copy link
Contributor Author

nmeier commented May 15, 2020

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.

@Phergus
Copy link
Contributor

Phergus commented May 15, 2020

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.

@Phergus Phergus added the tested This issue has been QA tested by someone other than the developer. label May 15, 2020
@Phergus
Copy link
Contributor

Phergus commented May 15, 2020

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

@JamzTheMan
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

6 participants