summaryrefslogtreecommitdiff
path: root/src/cairo-image-surface.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-05-25 02:28:09 -0700
committerCarl Worth <cworth@cworth.org>2006-06-05 14:25:21 -0700
commit3d9dc96d186c9093da24c7bbf36614f3d8df1758 (patch)
tree70a272b53379b24d38094c8d3ffb2d027152a217 /src/cairo-image-surface.c
parent0c49666231e42a3f968ad46a0aa58fc7b854b258 (diff)
New API: Add cairo_image_surface_get_{data,format,stride}
Diffstat (limited to 'src/cairo-image-surface.c')
-rw-r--r--src/cairo-image-surface.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 72c593f81..b5010c5b8 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -329,6 +329,50 @@ _cairo_image_surface_create_for_data_with_content (unsigned char *data,
}
/**
+ * 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)
{