mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Fix all of linter errors
This commit is contained in:
parent
e2a68c4ba4
commit
3835a3f0da
|
@ -89,24 +89,24 @@ func find_transparency_color_index(color_table: Dictionary) -> int:
|
|||
return -1
|
||||
|
||||
|
||||
func change_colors_to_codes(image: Image, color_palette: Dictionary, transparency_color_index: int) -> PoolByteArray:
|
||||
image.lock()
|
||||
var image_data: PoolByteArray = image.get_data()
|
||||
func colors_to_codes(img: Image, col_palette: Dictionary, transp_color_index: int) -> PoolByteArray:
|
||||
img.lock()
|
||||
var image_data: PoolByteArray = img.get_data()
|
||||
var result: PoolByteArray = PoolByteArray([])
|
||||
|
||||
for i in range(0, image_data.size(), 4):
|
||||
var color: Array = [image_data[i], image_data[i + 1], image_data[i + 2], image_data[i + 3]]
|
||||
|
||||
if color in color_palette:
|
||||
if color[3] == 0 and transparency_color_index != -1:
|
||||
result.append(transparency_color_index)
|
||||
if color in col_palette:
|
||||
if color[3] == 0 and transp_color_index != -1:
|
||||
result.append(transp_color_index)
|
||||
else:
|
||||
result.append(color_palette[color])
|
||||
result.append(col_palette[color])
|
||||
else:
|
||||
result.append(0)
|
||||
push_warning("change_colors_to_codes: color not found! [%d, %d, %d, %d]" % color)
|
||||
push_warning("colors_to_codes: color not found! [%d, %d, %d, %d]" % color)
|
||||
|
||||
image.unlock()
|
||||
img.unlock()
|
||||
return result
|
||||
|
||||
|
||||
|
@ -152,7 +152,7 @@ func add_frame(image: Image, frame_delay: float, quantizator: Script) -> int:
|
|||
if transparency_color_index == -1 and found_color_table.size() <= 255:
|
||||
found_color_table[[0, 0, 0, 0]] = found_color_table.size()
|
||||
transparency_color_index = found_color_table.size() - 1
|
||||
image_converted_to_codes = change_colors_to_codes(
|
||||
image_converted_to_codes = colors_to_codes(
|
||||
image, found_color_table, transparency_color_index
|
||||
)
|
||||
color_table = make_proper_size(found_color_table.keys())
|
||||
|
|
|
@ -147,6 +147,7 @@ func compress_lzw(image: PoolByteArray, colors: PoolByteArray) -> Array:
|
|||
return [binary_code_stream.pack(), min_code_size]
|
||||
|
||||
|
||||
# gdlint: ignore=max-line-length
|
||||
func decompress_lzw(code_stream_data: PoolByteArray, min_code_size: int, colors: PoolByteArray) -> PoolByteArray:
|
||||
var code_table: CodeTable = initialize_color_code_table(colors)
|
||||
var index_stream: PoolByteArray = PoolByteArray([])
|
||||
|
|
|
@ -443,26 +443,26 @@ func import_palette(path: String) -> void:
|
|||
file.open(path, File.READ)
|
||||
var text = file.get_as_text()
|
||||
file.close()
|
||||
palette = import_gpl(path, text)
|
||||
palette = _import_gpl(path, text)
|
||||
"pal":
|
||||
var file = File.new()
|
||||
if file.file_exists(path):
|
||||
file.open(path, File.READ)
|
||||
var text = file.get_as_text()
|
||||
file.close()
|
||||
palette = import_pal_palette(path, text)
|
||||
palette = _import_pal_palette(path, text)
|
||||
"png", "bmp", "hdr", "jpg", "jpeg", "svg", "tga", "webp":
|
||||
var image := Image.new()
|
||||
var err := image.load(path)
|
||||
if !err:
|
||||
palette = import_image_palette(path, image)
|
||||
palette = _import_image_palette(path, image)
|
||||
"json":
|
||||
var file = File.new()
|
||||
if file.file_exists(path):
|
||||
file.open(path, File.READ)
|
||||
var text = file.get_as_text()
|
||||
file.close()
|
||||
palette = import_json_palette(text)
|
||||
palette = _import_json_palette(text)
|
||||
|
||||
if palette:
|
||||
var palette_path := _save_palette(palette)
|
||||
|
@ -472,7 +472,7 @@ func import_palette(path: String) -> void:
|
|||
Global.palette_panel.select_palette(palette_path)
|
||||
|
||||
|
||||
func import_gpl(path: String, text: String) -> Palette:
|
||||
func _import_gpl(path: String, text: String) -> Palette:
|
||||
# Refer to app/core/gimppalette-load.c of the GIMP for the "living spec"
|
||||
var result: Palette = null
|
||||
var lines = text.split("\n")
|
||||
|
@ -522,7 +522,7 @@ func import_gpl(path: String, text: String) -> Palette:
|
|||
return result
|
||||
|
||||
|
||||
func import_pal_palette(path: String, text: String) -> Palette:
|
||||
func _import_pal_palette(path: String, text: String) -> Palette:
|
||||
var result: Palette = null
|
||||
var colors := PoolColorArray()
|
||||
var lines = text.split("\n")
|
||||
|
@ -548,7 +548,7 @@ func import_pal_palette(path: String, text: String) -> Palette:
|
|||
return result
|
||||
|
||||
|
||||
func import_image_palette(path: String, image: Image) -> Palette:
|
||||
func _import_image_palette(path: String, image: Image) -> Palette:
|
||||
var colors := []
|
||||
var height: int = image.get_height()
|
||||
var width: int = image.get_width()
|
||||
|
@ -571,7 +571,7 @@ func import_image_palette(path: String, image: Image) -> Palette:
|
|||
|
||||
|
||||
# Import of deprecated older json palette format
|
||||
func import_json_palette(text: String):
|
||||
func _import_json_palette(text: String) -> Palette:
|
||||
var result: Palette = Palette.new()
|
||||
var result_json = JSON.parse(text)
|
||||
|
||||
|
|
Loading…
Reference in a new issue