""" Copyright (C) 2013 Mayank Jha This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . """ """ Copyright (C) 2013 Mayank Jha This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . """ from PIL import Image def white_bg_square(img): "return a white-background-color image having the img in exact center" size = (max(img.size),)*2 layer = Image.new('1', size, 1) layer.paste(img, tuple(map(lambda x:(x[0]-x[1])/2, zip(size, img.size)))) return layer class BitmapCompare: def basicCompare(self,testbmp,standardsprite,size,xoffset,equal=False): master = Image.new('1',(size,size),0) img = Image.open(testbmp) square_one = white_bg_square(img) square_one.resize((size,size)) master.paste(square_one,(0,0)) master.save(testbmp) if equal: master = Image.new('1',(size,size),0) img = Image.open(standardsprite) square_one = white_bg_square(img) square_one.resize((size,size)) master.paste(square_one,(0,0)) master.save(standardsprite) sprite = Image.open(standardsprite) test = Image.open(testbmp) count = 0 i=0 while i