From b3e686758164203d680610fcb36a41a7a456de3c Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 23 Mar 2014 19:30:59 -0400 Subject: 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. --- pokemontools/gfx.py | 6 ++++-- 1 file 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: -- cgit v1.2.3