set_data
Description:
public bool set_data (uint8[] data, PixelFormat pixel_format, uint width, uint height, uint row_stride) throws Error
Sets the image data to be displayed by this.
If the image data was successfully loaded, the this will be invalidated.
In case of error, the error
value will be set, and this function will return false
.
The image data is copied in texture memory.
The image data is expected to be a linear array of RGBA or RGB pixel data; how to retrieve that data is left to platform specific image loaders. For instance, if you use the GdkPixbuf library:
ClutterContent *image = clutter_image_new ();
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
clutter_image_set_data (CLUTTER_IMAGE (image),
gdk_pixbuf_get_pixels (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf)
? COGL_PIXEL_FORMAT_RGBA_8888
: COGL_PIXEL_FORMAT_RGB_888,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
&error);
g_object_unref (pixbuf);
Parameters:
this |
a Image |
data |
the image data, as an array of bytes |
pixel_format |
the Cogl pixel format of the image data |
width |
the width of the image data |
height |
the height of the image data |
row_stride |
the length of each row inside |
Returns:
|