diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-12-24 00:36:06 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-12-24 00:36:06 +0100 |
commit | 6e2deea3d1b2fb4d79dac02a0d4310936c7f317c (patch) | |
tree | 05590a7d9f7cecde037aad7a5487ff2c62176932 /ui/bmp_texture.gd | |
parent | 7b3f386449aeab124d84d2aff4c273e646e68763 (diff) |
next commit
Diffstat (limited to 'ui/bmp_texture.gd')
-rw-r--r-- | ui/bmp_texture.gd | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/bmp_texture.gd b/ui/bmp_texture.gd new file mode 100644 index 0000000..54bf37b --- /dev/null +++ b/ui/bmp_texture.gd @@ -0,0 +1,19 @@ +class_name BMPTexture +extends ImageTexture + + +static func from_texture(texture: Texture2D, background_colors: Array[Color]) -> ImageTexture: + var image: Image = texture.get_image() + image.convert(Image.FORMAT_RGBA8) + + for x in image.get_width(): + for y in image.get_height(): + for color in background_colors: + if image.get_pixel(x, y).is_equal_approx(color): + image.set_pixel(x, y, Color.TRANSPARENT) + break + + var image_texture := ImageTexture.new() + image_texture.set_image(image) + + return image_texture |