New API: Add cairo_image_surface_get_{data,format,stride}

This commit is contained in:
Carl Worth 2006-05-25 02:28:09 -07:00
parent 0c49666231
commit 3d9dc96d18
2 changed files with 78 additions and 0 deletions

View file

@ -328,6 +328,50 @@ _cairo_image_surface_create_for_data_with_content (unsigned char *data,
width, height, stride);
}
/**
* cairo_image_surface_get_data:
* @surface: a #cairo_image_surface_t
*
* Get a pointer to the data of the image surface, for direct
* inspection or modification.
*
* Return value: a pointer to the image data of this surface or NULL
* if @surface is not an image surface.
**/
unsigned char *
cairo_image_surface_get_data (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
}
return image_surface->data;
}
/**
* cairo_image_surface_get_format:
* @surface: a #cairo_image_surface_t
*
* Get the format of the surface.
*
* Return value: the format of the surface
**/
cairo_format_t
cairo_image_surface_get_format (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
return image_surface->format;
}
/**
* cairo_image_surface_get_width:
* @surface: a #cairo_image_surface_t
@ -370,6 +414,31 @@ cairo_image_surface_get_height (cairo_surface_t *surface)
return image_surface->height;
}
/**
* cairo_image_surface_get_stride:
* @surface: a #cairo_image_surface_t
*
* Get the stride of the image surface in bytes
*
* Return value: the stride of the image surface in bytes (or 0 if
* @surface is not an image surface). The stride is the distance in
* bytes from the beginning of one row of the image data to the
* beginning of the next row.
**/
int
cairo_image_surface_get_stride (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
return image_surface->stride;
}
cairo_format_t
_cairo_format_from_content (cairo_content_t content)
{

View file

@ -1362,12 +1362,21 @@ cairo_image_surface_create_for_data (unsigned char *data,
int height,
int stride);
cairo_public unsigned char *
cairo_image_surface_get_data (cairo_surface_t *surface);
cairo_public cairo_format_t
cairo_image_surface_get_format (cairo_surface_t *surface);
cairo_public int
cairo_image_surface_get_width (cairo_surface_t *surface);
cairo_public int
cairo_image_surface_get_height (cairo_surface_t *surface);
int
cairo_image_surface_get_stride (cairo_surface_t *surface);
#if CAIRO_HAS_PNG_FUNCTIONS
cairo_public cairo_surface_t *