wdb_ripper.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:WDBRipper 作者: LiamBrandt 项目源码 文件源码
def export_gif(image, path, bin_file, pretext=""):
    """
    Create a PNG image based on a GIF image.

    The GIF data is specified in the dictionary image and contains formatted
    data based on the wdb structure. The PNG image is saved to path.
    """
    gif_name = get_raw(image["gif_name"], bin_file)
    width = get_raw(image["width"], bin_file)
    height = get_raw(image["height"], bin_file)
    num_colors = get_raw(image["num_colors"], bin_file)

    colors = []
    for color in image["colors"]:
        r = get_raw(color["r"], bin_file)
        g = get_raw(color["g"], bin_file)
        b = get_raw(color["b"], bin_file)
        colors.append((r, g, b))

    rows = []
    y = 0
    for row in image["rows"]:
        x = 0
        rows.append([])
        for pixel in row["pixels"]:
            color_index = get_raw(pixel["color_index"], bin_file)
            c = colors[color_index]
            for i in range(3):
                rows[y].append(c[i])

            x += 1
        y += 1

    #write png
    f = open(path + "/" + pretext + gif_name[:-4] + ".png", "wb")
    f.truncate()
    w = png.Writer(width, height)
    w.write(f, rows)
    f.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号