Method

ClutterImageset_data

Declaration [src]

gboolean
clutter_image_set_data (
  ClutterImage* image,
  const guint8* data,
  CoglPixelFormat pixel_format,
  guint width,
  guint height,
  guint row_stride,
  GError** error
)

Description [src]

Sets the image data to be displayed by image.

If the image data was successfully loaded, the image 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

data

Type: An array of guint8

The image data, as an array of bytes.

The data is owned by the caller of the method.
pixel_format

Type: CoglPixelFormat

The Cogl pixel format of the image data.

width

Type: guint

The width of the image data.

height

Type: guint

The height of the image data.

row_stride

Type: guint

The length of each row inside data.

error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE if the image data was successfully loaded, and FALSE otherwise.