Scaling without bluring the pixels?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Niclasa
Prole
Posts: 3
Joined: Thu Sep 28, 2017 11:42 am

Scaling without bluring the pixels?

Post 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
Attachments
gppcc11.zip
(18.11 KiB) Downloaded 133 times
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Scaling without bluring the pixels?

Post by grump »

Code: Select all

function love.load()
    love.graphics.setDefaultFilter("nearest", "nearest")
end
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Scaling without bluring the pixels?

Post 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
User avatar
Jummit
Prole
Posts: 1
Joined: Fri Dec 01, 2017 3:58 pm

Re: Scaling without bluring the pixels?

Post by Jummit »

This doesn't work when using

Code: Select all

love.graphics.scale()
. Everything is still blurred. Is it possible to change this filter, too?
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Scaling without bluring the pixels?

Post 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
Attachments
Cheeeers!! Point scale! 2017-12-01 22.46.48.png
Cheeeers!! Point scale! 2017-12-01 22.46.48.png (7.7 KiB) Viewed 4600 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests