diff --git a/src/Classes/ImageExtended.gd b/src/Classes/ImageExtended.gd index 8dd82cd64..d1555c63d 100644 --- a/src/Classes/ImageExtended.gd +++ b/src/Classes/ImageExtended.gd @@ -84,7 +84,7 @@ func update_palette() -> void: func convert_indexed_to_rgb() -> void: if not is_indexed: return - var palette_image := Palettes.current_palette.convert_to_image() + var palette_image := Palettes.current_palette.convert_to_image(false) var palette_texture := ImageTexture.create_from_image(palette_image) var shader_image_effect := ShaderImageEffect.new() var indices_texture := ImageTexture.create_from_image(indices_image) @@ -98,7 +98,7 @@ func convert_indexed_to_rgb() -> void: func convert_rgb_to_indexed() -> void: if not is_indexed: return - var palette_image := Palettes.current_palette.convert_to_image() + var palette_image := Palettes.current_palette.convert_to_image(false) var palette_texture := ImageTexture.create_from_image(palette_image) var params := { "palette_texture": palette_texture, "rgb_texture": ImageTexture.create_from_image(self) diff --git a/src/Palette/Palette.gd b/src/Palette/Palette.gd index 281384dd6..a59c895b4 100644 --- a/src/Palette/Palette.gd +++ b/src/Palette/Palette.gd @@ -25,7 +25,7 @@ var colors_max := 0 class PaletteColor: - var color := Color.TRANSPARENT + var color := Color(0, 0, 0, 0) var index := -1 func _init(init_color := Color.BLACK, init_index := -1) -> void: @@ -358,9 +358,11 @@ static func strip_unvalid_characters(string_to_strip: String) -> String: return regex.sub(string_to_strip, "", true) -func convert_to_image() -> Image: +func convert_to_image(crop_image := true) -> Image: var image := Image.create(colors_max, 1, false, Image.FORMAT_RGBA8) for i in colors_max: if colors.has(i): image.set_pixel(i, 0, Color(colors[i].color.to_html())) + if crop_image: + image.copy_from(image.get_region(image.get_used_rect())) return image