Hi, I'm trying to change the color of specific pixels on an image and it works, however, I get this warning every time I do so and I just want to know if there is any way of fixing it.
I get the following warning.
Loaded resource as image file, this will not work on export: 'res://Assets/Sprites/Player/Player_Idle0.png'. Instead, import the image file as an Image resource and load it normally as a resource.
That warning doesn't make the game crash or the function fail but I do change the color on the sprite quite often so I get this error as often.
Here's the code I'm using to change the color of specific pixels.
var secondary_color = color
secondary_color.v = color.v + 0.12
var image_path = "res://Assets/Sprites/Player/Player_Idle0.png"
var img = Image.new()
var itex = ImageTexture.new()
for w in range(img.get_width()):
for e in range(img.get_height()):
if img.get_pixel(e, w).g8 == 115 and img.get_pixel(e, w).b8 == 133 and img.get_pixel(e, w).r8 == 0:
img.set_pixel(e, w, secondary_color)
elif img.get_pixel(e, w).g8 == 89 and img.get_pixel(e, w).b8 == 103 and img.get_pixel(e, w).r8 == 0:
img.set_pixel(e, w, color)
$CenterContainer/VBoxContainer6/ColorSprite.texture = itex
It works fine except for that warning, and I did read that simply doing something like:
var img = load("res://Assets/Sprites/Player/Player_Idle0.png")
Would fix the problem, however, that returns a StreamTexture which cannot be modified like an Image.
Thx in advance.