0

added a fast resize function

Added resize_half() and resize_half_wrap() functions to composite.c and
overviewer.h, to replace the call to PIL's resize function made by
tileset.py. Also added "resize_half" to COverviewerMethods in main.c, so
it can be called from Python. Should increase performance by 10 to 20%
for the entire program.
This commit is contained in:
RamsesA
2012-07-03 20:26:23 -04:00
parent c79a646d10
commit 2b421d6d25
4 changed files with 165 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ from .files import FileReplacer
from .optimizeimages import optimize_image
import rendermodes
import c_overviewer
from c_overviewer import resize_half
"""
@@ -858,13 +859,17 @@ class TileSet(object):
# Create the actual image now
img = Image.new("RGBA", (384, 384), self.options['bgcolor'])
# we'll use paste (NOT alpha_over) for quadtree generation because
# this is just straight image stitching, not alpha blending
for path in quadPath_filtered:
try:
quad = Image.open(path[1]).resize((192,192), Image.ANTIALIAS)
#quad = Image.open(path[1]).resize((192,192), Image.ANTIALIAS)
src = Image.open(path[1])
src.load()
quad = Image.new("RGBA", (192, 192), self.options['bgcolor'])
resize_half(quad, src)
img.paste(quad, path[0])
except Exception, e:
logging.warning("Couldn't open %s. It may be corrupt. Error was '%s'", path[1], e)