小编Pla*_*aoo的帖子

转换PIL GdkPixbuf

如何在pixbuf中转换PIL图像?我试图改变许多例子,但没有解决方案

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)
Run Code Online (Sandbox Code Playgroud)

错误

TypeError: new_from_data () takes Exactly 9 arguments (7 given)
Run Code Online (Sandbox Code Playgroud)

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

python pygobject python-imaging-library gdkpixbuf

5
推荐指数
1
解决办法
2108
查看次数