>>>>> "William" == William R Dieter <[EMAIL PROTECTED]> writes:

    William> Is there a simple way to display raw 24-bit per pixel
    William> image with pyGTK without first writing the data out to a
    William> file?

If you compile pygtk with Numeric support (and recent versions of the
pygtk win32 binary have numeric support built in), you can use pixel
arrays.  In this example X us a MxNx4 (RGBA) pixel array
        
        # fill your array X        
        X.shape = cols, rows, 4
        pb=gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
                          has_alpha=1, bits_per_sample=8,
                          width=rows, height=cols)
        # earlier versions of pygtk had pixel_array attribute, newer
        # versions have the method get_pixels_array
        try: pa = pb.get_pixels_array()
        except AttributeError: pa = pb.pixel_array

        pa[:,:,:] = X

        gc = gdkDrawable.new_gc()
        pb.render_to_drawable(gdkDrawable, gc, 0, 0,
                              int(x), int(self.height-y), rows, cols,
                              gdk.RGB_DITHER_NONE, 0, 0)


For 24 bit images you can just set the alpha channel to a constant
value.

Cheers,
JDH
_______________________________________________
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