Can I downsize a texture?

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

…because I have 40x40 textures and texture for a mouse cursor must be smaller than 32x32 for some reason. Can I do that, or Is there any workaround? I’m using Godot 3.02. Thank you for your help.

Note that in Godot 3.1, the cursor size restriction will be lifted to 256×256.

Calinou | 2018-05-19 09:32

:bust_in_silhouette: Reply From: SIsilicon

You can indeed downsize a texture with the following steps.

  1. Get the texture’s image with get_data() method.
  2. Now with the image, you will resize it with resize(int width, int height).
  3. Create a new ImageTexture, then call create_from_image('your image').
  4. Ok to get that texture as your new mouse cursor use this line of code.


ProjectSettings.set_setting("display/mouse_cursor/custom_image", 'texture you made')

Altogether the code should look like this.

var image = 'Your original texture'.get_data()
image.resize(32, 32)
var texture =
ProjectSettings.set_setting("display/mouse_cursor/custom_image", texture)

Oh, I can get Image that way! Thank you, it worked!

Haseb | 2018-05-19 09:08