summaryrefslogtreecommitdiff
path: root/pokemontools
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2014-04-05 16:24:04 -0400
committeryenatch <yenatch@gmail.com>2014-04-05 16:24:04 -0400
commit5188de5a4e796ab96b6a38df3e296764d4d5e07d (patch)
tree17591ba087b5ede2d730f84cdf7fe86727ef4b0e /pokemontools
parent1c349f84a39eb1e567b821465297e27e7eb52257 (diff)
gfx: Don't pad images smaller than a tile.
Also fix a bug where images smaller than a tile are not converted at all.
Diffstat (limited to 'pokemontools')
-rw-r--r--pokemontools/gfx.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py
index 5457161..d6767fa 100644
--- a/pokemontools/gfx.py
+++ b/pokemontools/gfx.py
@@ -1454,12 +1454,12 @@ def get_image_padding(width, height, wstep=8, hstep=8):
'bottom': 0,
}
- if width % wstep:
+ if width % wstep and width >= wstep:
pad = float(width % wstep) / 2
padding['left'] = int(ceil(pad))
padding['right'] = int(floor(pad))
- if height % hstep:
+ if height % hstep and height >= hstep:
pad = float(height % hstep) / 2
padding['top'] = int(ceil(pad))
padding['bottom'] = int(floor(pad))
@@ -1543,15 +1543,15 @@ def png_to_2bpp(filein, **kwargs):
# Graphics are stored in tiles instead of lines
tile_width = 8
tile_height = 8
- num_columns = width / tile_width
- num_rows = height / tile_height
+ num_columns = max(width, tile_width) / tile_width
+ num_rows = max(height, tile_height) / tile_height
image = []
for row in xrange(num_rows):
for column in xrange(num_columns):
# Split it up into strips to convert to planar data
- for strip in xrange(tile_height):
+ for strip in xrange(min(tile_height, height)):
anchor = (
row * num_columns * tile_width * tile_height +
column * tile_width +