用于反冲的python绑定,复古计算机图像库
pyrecoil的Python项目详细描述
pyrecoil提供python绑定到RECOIL(复古计算机图像库),允许您从复古计算机打开200多个图像文件格式。
用法
from recoil import RecoilImage # load image from disk and decode it: img = RecoilImage("foo.lbm") # load image from an existing file handle: # (filename must still be provided, as a hint to the decoder) img = RecoilImage("foo.lbm", f) # inspecting properties: img.colors # number of colors used in the image > 16 img.frames # number of alternating frames (used for 'interlace' / 'gigascreen' effects) > 1 img.size # return a tuple of (width, height) > (320, 200) img.original_size # for images that have been resized to account for non-square pixels > (320, 200) img.platform > 'Amiga' # Retrieving pixel data - # returns a bytearray consisting of three bytes (r, g, b) for each pixel, # in left-to-right, top-to-bottom order pixels = img.get_pixels() # convert to a PIL / Pillow image object: pil_image = img.to_pil() pil_image.save('foo.png')
生成注释
反冲库本身(捆绑在recoil-3.2.0目录中)在Ć Programming Language中实现。为了便于分发,从citotranspiler生成的c输出(recoil.c和recoil.h)包含在包中,这与recoil_interface.c一起构成python扩展模块。