Page 1 of 1
Scaling without bluring the pixels?
Posted: Thu Sep 28, 2017 12:03 pm
by Niclasa
Is it possible to scale an image without the image being all blury im scaling by an int and if i asked this twice im an idiot and you can find my project in the attachments
thanks in common
Re: Scaling without bluring the pixels?
Posted: Thu Sep 28, 2017 12:12 pm
by grump
Code: Select all
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
end
Re: Scaling without bluring the pixels?
Posted: Fri Sep 29, 2017 6:47 pm
by Jasoco
Grump is correct. Though that does set the default. If you later need to have an image use smoothing, you can use "linear" instead of "nearest" and apply it to just that one image like so:
Code: Select all
image:setFilter("linear", "linear")
Also note that there are two arguments. The first one affects images being scaled down from full size, the second scaling up. So you can have shrunken images smooth out, but scaled up ones be pixeled if you want.
Also also note that there's also a third argument, anisotropy, which you can use if you want. It's not required.
Do yourself a favor and check out the Wiki:
https://love2d.org/wiki/love.graphics.setDefaultFilter
https://love2d.org/wiki/love.graphics.s ... mageFilter
https://love2d.org/wiki/(Image):setFilter
Re: Scaling without bluring the pixels?
Posted: Fri Dec 01, 2017 4:08 pm
by Jummit
This doesn't work when using
. Everything is still blurred. Is it possible to change this filter, too?
Re: Scaling without bluring the pixels?
Posted: Fri Dec 01, 2017 7:48 pm
by Sasha264
Jummit, this works perfect:
Code: Select all
function love.load()
love.window.setTitle("Cheeeers!! Point scale!")
img = love.graphics.newImage("enemy-mothership.png")
img:setFilter("nearest", "nearest")
end
function love.update(dt)
end
function love.draw()
love.graphics.scale(4)
love.graphics.draw(img)
end