summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-11-14 17:05:13 -0500
committeryenatch <yenatch@gmail.com>2013-11-17 16:27:03 -0500
commit45d2614affa0c7d38f430cba303673aee31f0aad (patch)
treeec9c250dad9c27a82f6b0240ea6bc439fc7ca9cb
parentf5ad14d634973ff6b340853df8b61bbdf61e0060 (diff)
gfx: 1bpp<->2bpp conversion
this is the simplest way to support 1bpp without rewriting a lot
-rw-r--r--pokemontools/gfx.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py
index c7c6bec..7583835 100644
--- a/pokemontools/gfx.py
+++ b/pokemontools/gfx.py
@@ -1453,6 +1453,19 @@ def png_to_lz(filein):
+def convert_2bpp_to_1bpp(data):
+ """
+ Convert planar 2bpp image data to 1bpp. Assume images are two colors.
+ """
+ return data[::2]
+
+def convert_1bpp_to_2bpp(data):
+ """
+ Convert 1bpp image data to planar 2bpp (black/white).
+ """
+ return type(data)(byte for byte in data for _ in (0, 1))
+
+
def mass_to_png(debug=False):
# greyscale