Scaling down sprite (BLURRY)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Brazda

Scaling down.

Have image(png - size 500x500) for object’s sprite(size 20x20).

I used scale ration 0.04 on object’s sprite but that effected how physics are applied to object later in game. So i don’t want that.

1.How to export and save object’s sprite image while game is running as .png?
2.Why are images that are scaled by other image editors when imported in godot blurry, but when i directly in godot scale them down, they are not?

I have seen that godot does a good job with scaling down (no blurry result) as opposed to paint or many other scaling down applications on internet.

Further reading:
I have been trying for whole day in Java to scale down image, and:
I just can’t understand why i couldn’t convert DataBufferByte to DataBufferInt


f = new File("pic1.png");
 image_i = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
 image_i =;
int[] pixels = ((DataBufferInt) image_i.getRaster().getDataBuffer()).getData(); 


java.lang.ClassCastException: java.awt.image.DataBufferByte cannot be cast to java.awt.image.DataBufferInt

I have also tried to implement scaling algorithm, as it can be seen here:

but this exception is stopping me.

For physics mentioned above, I had a bug in code. Physics are good. It was about some calculations for width and height of sprite.

Brazda | 2019-06-19 15:36

:bust_in_silhouette: Reply From: Zylann
  1. You can use Image.save_png() Image — Godot Engine (3.1) documentation in English
    Note: this is an Image method, so you need an Image (not a Texture, not a Sprite).

  2. They are blurry when imported maybe because you left the filter option on in the import settings. Double-click on your texture, uncheck the filter checkbox and click “Reimport”. You can save the config as default using the “Preset…” menu.

Also depending on what you really want to do, you might just need to make your image 20x20 in the first place so you don’t need to scale down?

I used scale ration 0.04 on object’s sprite but that effected how physics are applied to object later in game. So i don’t want that.

Then you could have the sprite as child of the body, and scale down ONLY the sprite?


 var image = get_node("sprite").get_texture().get_data();

but it saves a blurry image.

  1. I found option for filter, disabled him, and then clicked reimport, but nothing changed.
    3. I have sprite as a child of the body, and in whole this story i’m scaling sprite not the parent (Area2D) but somehow this scaling have impact on Area2D pyhsics.
  2. It is a lot easier to draw picture on canvas 500x500 then on 20x20.

Brazda | 2019-06-19 14:37

I wonder what are you trying to achieve in the first place?
In the code you pasted you basically told Godot to upload the texture to the graphics card, then download it back, then resize it and save it as a file… but why?

Zylann | 2019-06-19 18:28