My image is bleeding out hardly. Need an aid.

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
Gad
Prole
Posts: 2
Joined: Wed Feb 11, 2015 10:11 pm

My image is bleeding out hardly. Need an aid.

Post by Gad »

First of all:
I just started using love2d few days ago and I really appreciate the engine (even if I didn't code in lua before, lol).

Second:
I am using older love version (0.8), since I was learning from a tutorial coworking with AdvTiledLoader and I found out that newer versions doesn't support it.



I'm trying to crop a sprite from a spritesheet.

Code: Select all

function DrawSprite(object)
	finalcut = love.graphics.newQuad(0, 0, 37, 37, object.spriteSheet:getWidth(),object.spriteSheet:getHeight())
	
	
	love.graphics.drawq(object.spriteSheet, finalcut, 100, 100)
	
end
After resizing with love.graphics.scale(2.0, 2.0), it starts to bleed.

Image

And it's not only about the frame, but the image is blurred.



I've been trying to google the answer but all I found is 'use integer positions'.
I'm pretty sure that the numbers I use to blend the images are all integers.


Yeah and I know that using quad every frame may cause jamming, I'll rework it later, but for now I need an answer - can this be fixed?
Relazy
Citizen
Posts: 51
Joined: Thu Jul 10, 2014 11:10 pm

Re: My image is bleeding out hardly. Need an aid.

Post by Relazy »

Have a look at:
https://love2d.org/wiki/FilterMode

If you are always going to use the same wrap such as in your case as your game looks based on pixel art you may want to do the following in your load function:

Code: Select all

   love.graphics.setDefaultFilter( "nearest", "nearest")
Edit:
Sorry I missed the part at which you stated you used 0.8.0 in this case your function is:

Code: Select all

  love.graphics.setDefaultImageFilter( "nearest", "nearest")
Gad
Prole
Posts: 2
Joined: Wed Feb 11, 2015 10:11 pm

Re: My image is bleeding out hardly. Need an aid.

Post by Gad »

Thank you. This helped.
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: My image is bleeding out hardly. Need an aid.

Post by Tjakka5 »

Also, if you haven't already, modify the line where you draw your image to something like this:

Code: Select all

love.graphics.draw(player.img, math.floor(player.xPos+0.5), math.floor(player.yPos+0.5)
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: My image is bleeding out hardly. Need an aid.

Post by Muris »

Tjakka5 wrote:Also, if you haven't already, modify the line where you draw your image to something like this:

Code: Select all

love.graphics.draw(player.img, math.floor(player.xPos+0.5), math.floor(player.yPos+0.5)
I always thought the idea is to add 0.5 offset after flooring aka

Code: Select all

love.graphics.draw(player.img, math.floor(player.xPos)+0.5, math.floor(player.yPos)+0.5)
At least from what I tried in the past, if you draw lines on where its int value, it actually does not always draw them, but if you offset if by 0.5 it is more likely to draw lines. I am not too sure about images though
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

Re: My image is bleeding out hardly. Need an aid.

Post by DaedalusYoung »

Muris wrote:At least from what I tried in the past, if you draw lines on where its int value, it actually does not always draw them, but if you offset if by 0.5 it is more likely to draw lines. I am not too sure about images though
That only applies to lines and points. The int value of a pixel only points to the upper-left most point of the pixel, so drawing a line on int values actually tries to draw a line in between two pixels. If you want the line on one pixel, you have to draw it in the middle of the pixel, so at its int + 0.5 coordinate.

This does not apply to filled shapes or images, because you actually want them to be drawn from the top left position, so the 0,0 pixel of the image is on the 0,0 pixel of the screen.

Adding 0.5 before flooring actually rounds the float values to the nearest int, so it is more accurate than just flooring.
Post Reply

Who is online

Users browsing this forum: No registered users and 223 guests