CCZ——python压缩纹理成ccz

python压缩纹理资源 ===> ccz

import os
import struct
import zlib

def ccz(inputFile, outputFile, width, height):
    if not os.path.exists(inputFile):
        print("########: !!! error: " + inputFile)

    # orgin file to ccz
    size = os.path.getsize(inputFile)
    inputData = open(inputFile, "rb").read(size)
    outcczWriter = open(outputFile, "wb")
    outcczWriter.write(struct.pack(">4sHHII", "CCZ!", 0, 1, 0, size))
    outcczWriter.write(zlib.compress(inputData))
    outcczWriter.close()
    # os.remove(oriFile)
    print("gen ccz file => " + outputFile)

 

posted @ 2023-02-28 15:48  会飞的斧头  阅读(72)  评论(0编辑  收藏  举报