转换PIL GdkPixbuf [英] Converting PIL GdkPixbuf

查看:96
本文介绍了转换PIL GdkPixbuf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在pixbuf中转换PIL图像?我试图更改许多示例,但没有解决办法

How can I convert PIL Image in pixbuf?. I tried to change many examples but no solution

import array
from gi.repository import GdkPixbuf

def image2pixbuf(self,im):
    arr = array.array('B', im.tostring())
    height, width = im.size
    return GdkPixbuf.Pixbuf.new_from_data(arr, GdkPixbuf.Colorspace.RGB,
                                      True, 8, width, height, width * 4)

错误

TypeError: new_from_data () takes Exactly 9 arguments (7 given)

我使用Pygobject https://live.gnome.org/PyGObject

I use Pygobject https://live.gnome.org/PyGObject

推荐答案

您传递的参数少于方法new_from_data所需的参数.您始终可以查看C文档中的参数.

You are passing less arguments than required by the method new_from_data. You can always check the C documentation for the arguments.

这篇关于转换PIL GdkPixbuf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆