On Thu, 2008-10-16 at 19:04 +0200, Dirk Meyer wrote:

> But one question: how can a get the image data from a
> texture? I know that set_pixbuf is gone and I do not need it, but I need
> get_pixbuf. Is there a small piece of coding providing me that data
> somehow?

The replacement way to do this using the C API is to get a handle to the
cogl texture using clutter_texture_get_cogl_texture, get the data using
cogl_texture_get_data and then create a pixbuf using that. However it
looks like pyclutter doesn't bind the cogl_texture_* functions as far as
I can see. You could try this replacement snippet which uses ctypes in
the mean time:

import gtk
from ctypes import cdll

def get_texture_pixbuf (tex):
    lib = cdll.LoadLibrary(None)
    cogl_tex = hash(tex.get_property("cogl_texture"))
    
    width = lib.cogl_texture_get_width(cogl_tex)
    height = lib.cogl_texture_get_height(cogl_tex)

    data = ctypes.create_string_buffer('\000' * width * height * 4)

    lib.cogl_texture_get_data(cogl_tex,
                              19,
                              width * 4,
                              data)

    return gtk.gdk.pixbuf_new_from_data(data, gtk.gdk.COLORSPACE_RGB,
                                        True, 8, width, height, width * 4)


- Neil

-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to