0

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.

Larivact
  • 5
  • 4

1 Answers1

0

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 PIL.Image.frombytes(), PIL.Image.fromstring(), and other methods.

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

jcoppens
  • 5,306
  • 6
  • 27
  • 47