SpriteTools icon indicating copy to clipboard operation
SpriteTools copied to clipboard

Frames are 1 pixel smaller than they should be

Open ghost opened this issue 8 years ago • 9 comments

I'm importing frames and if the frame is supposed to be 13x13, I get an image that's 12x12. Why is that?

ghost avatar Jan 18 '17 18:01 ghost

Random guess: Your xleft and ytop are 1 too little (0, 0 is the top left corner of the sheet, not 0, 1)

I did notice that one image I was using had a horizontal strip missing in the middle, so I'll have to look into and patch/optimize that.

Bryce-Dixon avatar Jan 19 '17 01:01 Bryce-Dixon

Both are 0 :x

ghost avatar Jan 20 '17 02:01 ghost

Yeah, looking at this it seems like it's an issue with sf2d which is odd because it only happens with certain sprites (for me, link's standing left/right sprites). I'll do some investigating later

Bryce-Dixon avatar Jan 20 '17 02:01 Bryce-Dixon

Please do because it's an annoying bug D: I tried looking on the source what the issue could be but found nothing...

Also, I've noticed that when drawing an animation, the X and Y are sort of offset compared to drawing a spritesheet at the same X and Y. You might want to check that out...

ghost avatar Jan 21 '17 15:01 ghost

Also, I've noticed that when drawing an animation, the X and Y are sort of offset compared to drawing a spritesheet at the same X and Y.

This is because drawing a spritesheet at a given position makes that position the top left while an animation makes that the center. I did this because typically you're not really drawing your whole spritesheet as a character and instead just for testing, so there's no reason to get the position perfect. On the other hand, drawing an animation with the hotspot being in the top left corner can get irritating to recenter, so making the hotspot located at the center is more convenient.

I'll add some notes to the card on Trello for some thoughts that I want to look into. I really appreciate your patience with how slow I've been on getting this bug fixed and getting new features added, it's just that school takes up a ton of my time and I would rather get as far ahead on that as possible before getting caught up in a side project.

Bryce-Dixon avatar Jan 21 '17 16:01 Bryce-Dixon

Don't worry, thank you for the effort! It makes homebrew developing a million times easier considering the lack of documentation of citro3d and such. I'll probably end up contributing some code, I have a few ideas. I got it to work on C++ so I'll probably commit the changes later.

ghost avatar Jan 21 '17 17:01 ghost

I think it might be because you draw the frames from it's center compared to normal spritesheets, when you divide by half the width and height and the frame size is an odd number (like 13 or 15) you get a number with a .5 decimal, like 6.5 or 7.5, and when you draw a sprite in that position you get a skewed sprite since the x and y positions should never have decimals. Just have to put a floor() in the right place, I think.

ghost avatar Feb 06 '17 16:02 ghost

Hey, I'm not dead. Just in college.

So it turns out this is caused by an issue in sf2d (I looked in SpriteTools for like 30 minutes and couldn't see anything changing width/height or positions in the function chain). This means it'll only truly be fixed once I rewrite the low level graphics portion of ST which probably won't happen for a while.

In the mean time, I added a janky "fix" that just rounds the width and height up to the nearest even number. Is this a really stupid thing to do? Yes. Does it work well enough? Also yes.

Bryce-Dixon avatar Mar 07 '17 16:03 Bryce-Dixon