blob: 54bf37bc44ee6b5f7128c51b4caf7afa894cecdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
|