Class: Clutter::Image

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

The Clutter::ImageClass structure contains private data.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.newClutter::Content

Creates a new Clutter::Image instance.

Returns:

  • (Clutter::Content)

    the newly created Clutter::Image instance. Use g_object_unref() when done.

Instance Method Details

#set_area(data, pixel_format, rect, row_stride) ⇒ Boolean

Sets the image data to be display by image, using rect to indicate the position and size of the image data to be set.

If the image does not have any image data set when this function is called, a new texture will be created with the size of the width and height of the rectangle, i.e. calling this function on a newly created Clutter::Image will be the equivalent of calling clutter_image_set_data().

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.

Parameters:

  • data (Array<Integer>)

    the image data, as an array of bytes

  • pixel_format (Cogl::PixelFormat)

    the Cogl pixel format of the image data

  • rect (cairo::RectangleInt)

    a rectangle indicating the area that should be set

  • row_stride (Integer)

    the length of each row inside data

Returns:

  • (Boolean)

    true if the image data was successfully loaded, and false otherwise.

#set_bytes(data, pixel_format, width, height, row_stride) ⇒ Boolean

Sets the image data stored inside a #GBytes 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 contained inside the #GBytes is copied in texture memory, and no additional reference is acquired on the data.

Parameters:

  • data (GLib::Bytes)

    the image data, as a #GBytes

  • pixel_format (Cogl::PixelFormat)

    the Cogl pixel format of the image data

  • width (Integer)

    the width of the image data

  • height (Integer)

    the height of the image data

  • row_stride (Integer)

    the length of each row inside data

Returns:

  • (Boolean)

    true if the image data was successfully loaded, and false otherwise.

#set_data(data, pixel_format, width, height, row_stride) ⇒ Boolean

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 (Array<Integer>)

    the image data, as an array of bytes

  • pixel_format (Cogl::PixelFormat)

    the Cogl pixel format of the image data

  • width (Integer)

    the width of the image data

  • height (Integer)

    the height of the image data

  • row_stride (Integer)

    the length of each row inside data

Returns:

  • (Boolean)

    true if the image data was successfully loaded, and false otherwise.