Tim Evans wrote:
> [snip]
I'm not sure about 1.99.14, but 1.99.16 can be compiled with Numeric support. If it is you can create a Pixbuf by modifying the array returned be accessing the 'pixel_array' attribute of an existing pixbuf.

Assuming that you have a (n,m,3) or (n,m,4) shape 'b' type array of RGB or RGBA values called 'data', you would do this:

w,h = data.shape[:2]
hasalpha = shape.shape[3] == 4
p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, hasalpha, 8, w, h)
p.pixel_array[:] = data

I just noticed that the above is only working because of luck. The width and height of the pixbuf were being put in the array dimensions in the wrong order. In some cases this can even cause a segfault.


See http://bugzilla.gnome.org/show_bug.cgi?id=118839 for a patch.

--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to