aboutsummaryrefslogtreecommitdiff
path: root/assets/addons/voxel-core/classes/readers/image.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-15 16:29:02 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-15 16:29:02 +0100
commitc9c5b5d7c2a238310ce7bde336f76d2d1b6f9f29 (patch)
treec6e935fea995752a0b307e56892e8422fb734c0e /assets/addons/voxel-core/classes/readers/image.gd
parent98f356e68b759bf84300290315d4ada09c41f79b (diff)
moved shapes to loading area & fixed asset paths
Diffstat (limited to 'assets/addons/voxel-core/classes/readers/image.gd')
-rw-r--r--assets/addons/voxel-core/classes/readers/image.gd40
1 files changed, 0 insertions, 40 deletions
diff --git a/assets/addons/voxel-core/classes/readers/image.gd b/assets/addons/voxel-core/classes/readers/image.gd
deleted file mode 100644
index 3c19d2f..0000000
--- a/assets/addons/voxel-core/classes/readers/image.gd
+++ /dev/null
@@ -1,40 +0,0 @@
-class_name ImageReader, "res://addons/voxel-core/assets/logos/MagicaVoxel.png"
-extends Reference
-# Image file reader
-
-
-
-## Public Methods
-# Reads images pixels, returns voxel content and voxel palette
-static func read(image : Image) -> Dictionary:
- var result := {
- "error": OK,
- "voxels": {},
- "palette": [],
- }
-
- image.lock()
- for x in range(image.get_width()):
- for y in range(image.get_height()):
- if image.get_pixel(x, y).a > 0:
- var color := image.get_pixel(x, y)
- color.a = 1.0
- var index = result["palette"].find(color)
- if index == -1:
- index = result["palette"].size()
- result["palette"].append(color)
- result["voxels"][Vector3(x, -y, 0).round()] = index
- image.unlock()
-
- for index in range(result["palette"].size()):
- result["palette"][index] = Voxel.colored(result["palette"][index])
-
- return result
-
-
-static func read_file(image_path : String) -> Dictionary:
- var image := Image.new()
- var err = image.load(image_path)
- if err == OK:
- return read(image)
- return { "error": err }