summaryrefslogtreecommitdiff
path: root/pokemontools/gfx.py
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2014-03-23 19:30:59 -0400
committeryenatch <yenatch@gmail.com>2014-03-23 19:30:59 -0400
commitb3e686758164203d680610fcb36a41a7a456de3c (patch)
treeb6eceb7f71788a02140f4b132cabe62da31727fb /pokemontools/gfx.py
parent12d8bb11e82ba44ee6a04a52497381833a7b5924 (diff)
gfx: Prefer heights not divisible by 8, rather than forcing them.
Some images do not occupy a full tile. In pokered, gfx/minimize_pic.1bpp is 8x5. This is still rectangular. Previously, converting this image would cause an error.
Diffstat (limited to 'pokemontools/gfx.py')
-rw-r--r--pokemontools/gfx.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py
index 3db8818..5821759 100644
--- a/pokemontools/gfx.py
+++ b/pokemontools/gfx.py
@@ -1298,13 +1298,15 @@ def convert_2bpp_to_png(image, width=0, height=0, pal_file=None, tile_padding=0)
if width * height != num_pixels:
# look for possible combos of width/height that would form a rectangle
matches = []
+ # Height need not be divisible by 8, but width must.
+ # See pokered gfx/minimize_pic.1bpp.
for w in range(8, num_pixels / 2 + 1, 8):
h = num_pixels / w
- if w * h == num_pixels and h % 8 == 0:
+ if w * h == num_pixels:
matches += [(w, h)]
# go for the most square image
if len(matches):
- width, height = sorted(matches, key= lambda (w, h): w + h)[0] # favor height
+ width, height = sorted(matches, key= lambda (w, h): (h % 8 != 0, w + h))[0] # favor height
# if it still isn't rectangular then the image isn't made of tiles
if width * height != num_pixels: