Add a public cogl_bitmap_new_for_data
This creates a CoglBitmap which points into an existing buffer in system memory. That way it can be used to create a texture or to read pixel data into. The function replaces the existing internal function _cogl_bitmap_new_from_data but removes the destroy notify call back. If the application wants notification of destruction it can just use the cogl_object_set_user_data function as normal. Internally there is now a convenience function to create a bitmap for system memory and automatically free the buffer using that mechanism. The name of the function is inspired by cairo_image_surface_create_for_data which has similar semantics. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
@ -129,6 +129,34 @@ cogl_bitmap_new_with_size (CoglContext *context,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_new_for_data:
|
||||
* @context: A #CoglContext
|
||||
* @width: The width of the bitmap.
|
||||
* @height: The height of the bitmap.
|
||||
* @format: The format of the pixel data.
|
||||
* @rowstride: The rowstride of the bitmap (the number of bytes from
|
||||
* the start of one row of the bitmap to the next).
|
||||
* @data: A pointer to the data. The bitmap will take ownership of this data.
|
||||
*
|
||||
* Creates a bitmap using some existing data. The data is not copied
|
||||
* so the application must keep the buffer alive for the lifetime of
|
||||
* the #CoglBitmap. This can be used for example with
|
||||
* cogl_framebuffer_read_pixels_into_bitmap() to read data directly
|
||||
* into an application buffer with the specified rowstride.
|
||||
*
|
||||
* Return value: A new #CoglBitmap.
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
CoglBitmap *
|
||||
cogl_bitmap_new_for_data (CoglContext *context,
|
||||
int width,
|
||||
int height,
|
||||
CoglPixelFormat format,
|
||||
int rowstride,
|
||||
guint8 *data);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_get_format:
|
||||
* @bitmap: A #CoglBitmap
|
||||
|
Reference in New Issue
Block a user