此处写了一个简单的ant的脚本,实现了pvr格式到png的转换,借助的是TexturePacker 命令行工具,该工具非常强大。
<?xml version="1.0" encoding="UTF-8"?>
<project name="pvr/png convertor" default="pvr2png">
<!--Description: pvr/png convertor -->
<!--Author: terran.tian@foxmail.com -->
<!--Date: 2014年4月11日 下午1:21:52 -->
<property name="ant_dir" location="antlib" />
<path id="classpath">
<fileset dir="${ant_dir}" includes="**/*.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="classpath" />
<property name="pvrFolder"
value="/Users/terran/Documents/workspace/assets/res/images"/>
<target name="pvr2png">
<for param="file">
<path id="p">
<fileset
dir="${pvrFolder}">
<include name="**/*.pvr.ccz" />
<include name="**/*.pvr" />
</fileset>
</path>
<sequential>
<propertyregex override="yes" property="file0" input="@{file}"
regexp="${pvrFolder}/(\S+)\.pvr(\.ccz)*" replace="\1"/>
<echo>${file0}</echo>
<exec executable="TexturePacker" failοnerrοr="true">
<arg
line="--format cocos2d --data temp/${file0}.plist
--sheet temp/${file0}.png
--opt RGBA8888 --dither-fs-alpha
--max-width 2048 --max-height 2048 --size-constraints NPOT
--border-padding 0 --shape-padding 0
--algorithm MaxRects --maxrects-heuristics Best
--disable-rotation --trim-mode Trim @{file}" />
</exec>
<delete file="temp/${file0}.plist"/>
</sequential>
</for>
</target>
</project>