DynamicSprite Resize function's utility

Started by Baguettator, Fri 07/01/2022 14:57:47

Previous topic - Next topic

Baguettator

Hi there !

I tried to use the resize function on DynamicSprite, but I felt it was not really well working. The image is maybe too complex, and so it's more "pixelized", and not so precise as expected.

Any way to have this function working better in AGS ? Or is there a reason of that ? Or a module that could help ?

Crimson Wizard

Dynamic sprites are resized as raw bitmaps in their own resolution of course, using most trivial nearest-neighbour method.
It is also important to remember to not resize already resized sprite again, but resize from original sprite all the time, because when you continuously resizing a dynamic sprite it will be getting worse and worse every time (same as with rotating).

Depending on what you are trying to do, but in theory you may get better results by applying original sprite to the room object or character and scaling that object or character instead.
If you have "Render sprites at screen resolution" option enabled in setup, these objects will be rescaled in the window resolution.

Baguettator

#2
Quoteusing most trivial nearest-neighbour method.

Do you mean it's a method that is not very good ?

What I'm trying to do is to create several sprites from one sprite. It will allow to decrease the game's size because many sprites will be created when the game is launched. They use the sprite (that is already in the game) and resize it smaller and put it on another background. But the main reason is that I allow the player to add his own sprites (from files on his computer), and so in this case I automatically create the other sprites from his "custom" image, instead of asking him "create another sprite using the first one and putting it on the background I gave you with the game".

Not sure if it's clear, but it's really useful to do that. Until now, it seems that resizing a 140*140 sprite into a 30*30 one gave me an ugly result.

EDIT : well maybe it's because I resize it too much ?

Crimson Wizard

#3
Quote from: Baguettator on Fri 07/01/2022 16:59:43
Until now, it seems that resizing a 140*140 sprite into a 30*30 one gave me an ugly result.

EDIT : well maybe it's because I resize it too much ?

Erm, indeed! You have 140 pixels and want to somehow accomodate them into 30? Afaik, nearest-neighour method downscales basically by skipping pixels; it does not "merge" the colors to create a better illusion of same image.
Usually when there's so much scaling with pixel graphics it's best to create at least few "key frames" at varying scales.


Quote from: Baguettator on Fri 07/01/2022 16:59:43
They use the sprite (that is already in the game) and resize it smaller and put it on another background.

So, this is supposed to be a part of the room background? Perhaps if you try the method with scaled down object or character it may work better (assuming you have "Render sprites at screen resolution" enabled).  I cannot 100% guarantee that would be suitable, because there may be other problems with that, but it's one option.

Maybe there are other solutions, which i cannot think of right away.
Like, in theory, one could make a module or a plugin that uses different scale filter. Although, I have doubts that any filter may downscale that much and keep good quality.

SMF spam blocked by CleanTalk