Option to turn off image smoothing in Viewer

I really enjoy the new GPU image viewer.

Following up on a request from years ago, I would love to see a command to toggle image smoothing.

As the new viewer has been rewritten with Direct2D, I hope implementing this won't be too hard.

Thanks for considering this.

It's already there:

Regards
Guido

Preferences / Viewer / Standalone Viewer / High quality scaling

Preferences / Viewer / Viewer Pane / High quality scaling

I know this option exists.

But in reality, even with this option turned off, the image still gets resampled. TBH, I can't tell the difference in the final image whether this option is on or off.

If I just turn off 'accelerated rendering' the upscaled image is super sharp, but obviously, I can't disable it since I need GPU acceleration.

Also, I hope there will be a command that can be placed on the image toolbar to toggle resampling anytime.

Would like to see this too. Thanks!

I find that Intel has special options for "Retro Scaling", Integer scaling (IS), and Nearest-neighbor (NN) scaling for their GPU:

These options affect full-screen display apparently, perhaps there are similar options in Direct2D API?

Regards
Guido

Yeah, it seems that d2d has several interpolation modes. I guess using D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR when drawing bitmaps will do. I don't know much about d2d.

I would also very much love to have options for scaling/filtering method!

If added, please make the method for zooming in vs. zooming out separate to support different image workflow needs.

I.e., so we can have good quality when zoomed out, without making pixels blurry if zooming in. (Of course, pixel distortions would still be natural unless zoomed in by multiples.)

We've added options to exactly specify the zoomed in/out scaling methods in the next beta. Thanks for the suggestions!

Many thanks!

Thank you so much, Jon.

Could you please add some commands to set the current scaling method?
Which scaling method to use really depends on what kind of image you're viewing.

For photos, high-quality scaling is great, but for small icons or pixel-style images, nearest-neighbor works better. Changing this in the preferences isn't very convenient.

hmmm, yes please :slight_smile: +1

I did that with AHK :slightly_smiling_face:.

AutoHotKey v2 is required to run this script.

SetScalingMethod.ahk.txt (1.8 KB)
Usage:

AutoHotkey64.exe "D:\SetScalingMethod.ahk" <Zoom in/out scaling method> [Zoom out scaling method]

Available scaling methods (same as the values in the dropdown menu in Preferences) :

  • Nearest neighbor
  • Linear
  • Cubic
  • Linear (multi-sample)
  • Anisotropic
  • High quality cubic

The script accepts one or two arguments. If only one argument is provided, it will use this scaling method for both zooming in and out. Otherwise, you can specify separate scaling methods for zooming in and out.

This script relies on the currently active window being a standalone viewer window to find the image viewer child window, so when using this script, make sure the active window is the viewer window (meaning you need to click the button directly on the viewer toolbar, not "Run" in an opened command editor).

Examples:

AutoHotkey64.exe "D:\SetScalingMethod.ahk" "Nearest neighbor" // Sets both zoom in and out methods to Nearest neighbor

"D:\SetScalingMethod.ahk" "Nearest neighbor" "Cubic" // Nearest neighbor for zoom in, Cubic for zoom out

Here’s the code:

#Requires AutoHotkey v2.0
#SingleInstance Force

global InterpolationModes := Map(
	"Nearest neighbor",      0,
	"Linear",                1,
    "Cubic",                 2,
    "Linear (multi-sample)", 3,
    "Anisotropic",           4,
    "High quality cubic",    5,
)


if (A_Args.Length < 1)
{
    MsgBox("Error: Please provide the scaling method parameter.", "Error", 0x10)
    ExitApp(2)
}

try {
	modeA  := A_Args[1]
	modeB  := (A_Args.Length == 2) ? A_Args[2] : modeA
    wParam := CalcWParam(modeA, modeB)
} catch Error as err {
    MsgBox(err.Message, "Error", 0x10)
    ExitApp(2)
}

activeHWnd := WinExist("A")
if (!activeHWnd)
{
    ExitApp(3)
}

try {
    OpusPicViewerHWnd := ControlGetHwnd("dopus.viewpic1", activeHWnd)
} 
catch {
    OpusPicViewerHWnd := WinExist("ahk_class dopus.viewpic ahk_parent " activeHWnd)
    if (!OpusPicViewerHWnd) 
    {
        for ctrlHwnd in WinGetControlsHwnd(activeHWnd) 
        {
            if (WinGetClass(ctrlHwnd) == "dopus.viewpic")
            {
                OpusPicViewerHWnd := ctrlHwnd
                break
            }
        }
    }
}

if (!OpusPicViewerHWnd)
{
    ExitApp(3)
}


WM_APP := 0x8000
msg := WM_APP + 3914

result := SendMessage(msg, wParam, 0, OpusPicViewerHWnd)
if(result == 1)
{
	ExitApp(0)
}
ExitApp(1)

CalcWParam(modeZoomIn, modeZoomOut)
{
    modeZoomIn  := Trim(modeZoomIn)
    modeZoomOut := Trim(modeZoomOut)
     
    if (!InterpolationModes.Has(modeZoomIn) || !InterpolationModes.Has(modeZoomOut)) 
	{
        throw Error("Unknown scaling method")
    }
    
    codeZoomIn  := InterpolationModes[modeZoomIn]
    codeZoomOut := InterpolationModes[modeZoomOut]
    wParam := (codeZoomOut << 12) + (codeZoomIn << 8) + 0x01
    return wParam
}

We'll add commands for that in the next beta.