wc_common.py 文件源码

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

项目:wahcade 作者: sairuk 项目源码 文件源码
def pil_image_to_pixbuf(self, image_fn, angle):
        """use Python Image Library (PIL) to load an image, rotate it, and return as a pixbuf)
        """
        pixbuf = None
        if os.path.isfile(image_fn):
            pil_image = PIL.Image.open(image_fn)
            if angle is not 0:
                pil_image = pil_image.rotate(angle,PIL.Image.BICUBIC,1)
            fd = StringIO.StringIO()
            pil_image.save(fd, "png")
            contents = fd.getvalue()
            fd.close()
            loader = gtk.gdk.PixbufLoader("png")
            loader.write(contents, len(contents))
            pixbuf = loader.get_pixbuf()
            loader.close()
        #done
        return pixbuf
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号