shithub: pokecrystal

Download patch

ref: 21a9fac5d04c5865ccdeac28e236067907a420c0
parent: f6fc07d1c9fc1fdf9d95842d59879450b98fa721
author: yenatch <yenatch@gmail.com>
date: Wed Feb 17 13:08:11 EST 2016

Decompress images in one step instead of having to invoke 'unlz'.

--- a/gfx.py
+++ b/gfx.py
@@ -58,6 +58,8 @@
 		filedir = filedir[2:]
 
 	name, ext = os.path.splitext(filename)
+	if ext == '.lz':
+		name, ext = os.path.splitext(name)
 
 	pokemon_name = ''
 
@@ -104,22 +106,31 @@
 
 
 def to_1bpp(filename, **kwargs):
-	_, ext = os.path.splitext(filename)
+	name, ext = os.path.splitext(filename)
 	if   ext == '.1bpp': pass
 	elif ext == '.2bpp': gfx.export_2bpp_to_1bpp(filename, **kwargs)
 	elif ext == '.png':  gfx.export_png_to_1bpp(filename, **kwargs)
+	elif ext == '.lz':
+		decompress(filename, **kwargs)
+		to_1bpp(name, **kwargs)
 
 def to_2bpp(filename, **kwargs):
-	_, ext = os.path.splitext(filename)
+	name, ext = os.path.splitext(filename)
 	if   ext == '.1bpp': gfx.export_1bpp_to_2bpp(filename, **kwargs)
 	elif ext == '.2bpp': pass
 	elif ext == '.png':  gfx.export_png_to_2bpp(filename, **kwargs)
+	elif ext == '.lz':
+		decompress(filename, **kwargs)
+		to_2bpp(name, **kwargs)
 
 def to_png(filename, **kwargs):
-	_, ext = os.path.splitext(filename)
+	name, ext = os.path.splitext(filename)
 	if   ext == '.1bpp': gfx.export_1bpp_to_png(filename, **kwargs)
 	elif ext == '.2bpp': gfx.export_2bpp_to_png(filename, **kwargs)
 	elif ext == '.png':  pass
+	elif ext == '.lz':
+		decompress(filename, **kwargs)
+		to_png(name, **kwargs)
 
 def compress(filename, **kwargs):
 	data = open(filename, 'rb').read()
--