[]关于Button Skin 切图问题

美术工作按laya button 规则切图的时候总是会出现一两个像素对不齐的情况
例如默认状态时xia下面会看到hua划过或点击状态sha上面的边!!!
刚试了下用python 写了个简单的脚本 应该能让切图轻松一些把
 
mport os
import math
from PIL import Image 
# if png
pngs=[]
maxWith = 0
maxHeight = 0
for idx in range(1,4):
fname = os.path.join( os.path.curdir, "btn_{0}.png".format(idx))
if os.path.exists( fname) :
im=Image.open( fname)
pngs.append( im)
maxWith = max( maxWith, im.width)
maxHeight = max( maxHeight, im.height)
print im.width, im.height
length=len(pngs)
maxHeight += 2
if length > 0:
finalHeight = maxHeight*length
outIm = Image.new('RGBA',(maxWith, finalHeight), (0,0,0,0))
index=0
for im in pngs:
left = (maxWith - im.width)*0.5
top = index*maxHeight + (maxHeight - im.height) *0.5
outIm.paste( im, (int(left), int(top)))
index = index + 1
print('paste', left, top)
outIm.save( os.path.join(os.path.curdir, "button.png"))
else:
print("请确定图片是否存在!")
 
已邀请:

Aar0n

赞同来自:

感谢分享

要回复问题请先

商务合作
商务合作