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

Incorrect image scaling with system zoom on Windows #2155

Open
Yolwoocle opened this issue Feb 17, 2025 · 3 comments
Open

Incorrect image scaling with system zoom on Windows #2155

Yolwoocle opened this issue Feb 17, 2025 · 3 comments
Labels

Comments

@Yolwoocle
Copy link

On LÖVE 12 (I am using this commit), images don't scale correctly when on high DPI screens, or said otherwise, when the system zoom is set at a non-multiple of 100%.

Here is a minimal example that draws a diagonal like of single pixels onto a canvas, then draws the canvas at x4 scale. I am on Windows 11, with a system zoom of 150%. The image below the shows the output of love.graphics.captureScreenshot, which is also what it looks like visually. You can see that the pixels' size are uneven.

I have not tested this on other operating systems.

function love.load()
    love.graphics.setDefaultFilter("nearest", "nearest")
    love.window.setMode(1028, 1028, {
        resizable = true,
        minwidth = 128,
	minheight = 128,
    })

    canvas = love.graphics.newCanvas(128, 128)
end

function love.draw()
    love.graphics.setCanvas(canvas)
    love.graphics.clear(0, 0, 0, 1)
    for i=0, 127 do
        love.graphics.points(math.floor(i) + 0.5, math.floor(i) + 0.5)
    end
    love.graphics.setCanvas()

    love.graphics.origin()   
	love.graphics.scale(1, 1)
    love.graphics.setColor(1, 1, 1, 1)
    love.graphics.draw(canvas, 0, 0, 0, 4, 4)
end

Image

@slime73
Copy link
Member

slime73 commented Feb 17, 2025

The behaviour is likely correct for how high DPI currently works (i.e. love 11's design), the size you give to a canvas is DPI-scaled by default and coordinates are in DPI-scaled units by default.

@Yolwoocle
Copy link
Author

This doesn't happen on LÖVE 11, though. So using DPI-scaled units inside canvas is an intended behavior? My problem with that is that it gives some quite ugly results on high-DPI screens, by default. I know that you can set dpiscale = 1 in the Canvas' settings, but this seems to be something that could be easily overlooked by a developer, especially if they are not on a high-DPI screen. Since Canvases are usually meant to be drawn in one way or another afterwards, do you think that it would be reasonable to set the dpiscale to 1 by default?

@slime73
Copy link
Member

slime73 commented Feb 17, 2025

It will happen that way on Android in love 11. And on macOS and Wayland-Linux if you enable high dpi.

In love 11, DPI scaling was always system-managed in Windows (it would scale your backbuffer and make everything blurry). Right now in love 12 it's always app-managed like how Android behaves in love 11.

I recommend reading up on love's high dpi documentation, for example the options in love.conf. That being said, further reworks of DPI scaling support are planned for love 12 because Windows is extremely messy with how it expects multiple coordinate systems to be used, unlike macOS or Wayland.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants