From 45d2614affa0c7d38f430cba303673aee31f0aad Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 14 Nov 2013 17:05:13 -0500 Subject: gfx: 1bpp<->2bpp conversion this is the simplest way to support 1bpp without rewriting a lot --- pokemontools/gfx.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 -- cgit v1.2.3