简体   繁体   中英

Creating a Gtk.Image from a pixel list

I am working on a GTK program that manipulates an image based on user input. I am using pypng to read the image and am now looking for a way to create a Gtk.Image from a pixel list without creating an intermediate image file.

Not entirely easy to do in Python directly. You could do this, using GtkImage , which can load images from a GdkPixbuf.Pixbuf using a method called from_pixdata() .

A higher level of doing this is using (for example) the PIL (in python2 ) or Pillow ( python3 ) . There, you can construct images using the Image module and the P IL.Image.frombytes() , PIL.Image.fromstring() , and other methods.

There are also functions in matplotlib which convert arrays immediately to images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM