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.
func _on_ColorPickerButton_color_changed(color):
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()
img.load(image_path)
img.lock()
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)
img.unlock()
itex.create_from_image(img)
$CenterContainer/VBoxContainer6/ColorSprite.texture = itex
$CenterContainer/VBoxContainer6/ColorSprite.texture.set_flags(1)
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.