求助大佬们这个文件怎么转成PNG

result_data.zip (407.4 KB) 一个游戏加密了 通过调试得到了这个文件 有个format字段对应的值是COMPRESSED_RGBA_BPTC_UNORM_EXT: 0x8e8c 止步于此了 不知道怎么把COMPRESSED_RGBA_BPTC_UNORM_EXT格式的转成png

import texture2ddecoder
from PIL import Image
import math

def bptc_to_png(raw_data_path, output_png_path, width = None, height = None):
    with open(raw_data_path, 'rb') as f:
        bptc_data = f.read()

    file_size = len(bptc_data)
    if width is None or height is None:
        total_pixels = file_size
        side = int(math.isqrt(total_pixels))
        if side * side != total_pixels:
            raise ValueError(f"{file_size} 非完全平方数 ")
        width = height = side
        print(f"宽高: {width} x {height}")

    rgba_data = texture2ddecoder.decode_bc7(bptc_data, width, height)
    img = Image.frombytes("RGBA", (width, height), rgba_data, 'raw', "BGRA")

    img.save(output_png_path, "PNG")
    print(f"成功保存至: {output_png_path}")


bptc_to_png(r"C:\Users\86182\Downloads\result_data", r"C:\Users\86182\Downloads\output.png")

你给的是裸数据,这里大小是4,194,304 字节,所以直接开根号得到宽高2048*2048

公若不弃布愿拜为义父 :star_struck: