[cairo] How to export image_surface pixel data?

Carl Worth cworth at cworth.org
Tue Jan 17 15:20:02 PST 2006


On Mon, 26 Sep 2005 09:07:16 +0800, Steve Chaplin wrote:
>
> There does not seem to be a corresponding function to allow the export
> of pixel data from cairo. I'd expect there to be something like
>   "unsigned char *data = cairo_image_surface_get_data()"

[Copying the bug report:
 http://lists.freedesktop.org/archives/cairo/2005-September/005364.html
]

We clearly need this. And I'd like to shove something in before we
release cairo 1.2.0 (it turns out some improvements to the test suite
would really like to be able to do this after
cairo_image_surface_create_from_png).

There is something missing though from the proposed interface. In
order to really be able to use the image data, one will need the
following information in addition to a pointer to the data:

	format, width, height, stride

Two of these are available already in:

	cairo_public int
	cairo_image_surface_get_width (cairo_surface_t *surface);
and:
	cairo_public int
	cairo_image_surface_get_height (cairo_surface_t *surface);

Do we want to add the remaining three functions in a piece-wise
fashion:

	cairo_public cairo_format_t
	cairo_image_surface_get_format (cairo_surface_t *surface);

	cairo_public unsigned char *
	cairo_image_surface_get_data (cairo_surface_t *surface);

	cairo_public int
	cairo_image_surface_get_stride (cairo_surface_t *surface);

Or would it be better to have one call to get them all (in
an order to match cairo_image_surface_create_for_data)?

	cairo_public void
	cairo_image_surface_get_data (cairo_surface_t	 *surface,
				      unsigned char	**data,
				      cairo_format_t	 *format,
				      int		 *width,
				      int		 *height,
				      int		 *stride);

The idea being that getting the data without the other information is
either not useful or at best error-prone, and having to call five
functions for a single operation is just painful.

Get your votes in quick if you care.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060117/d83a02b6/attachment.pgp


More information about the cairo mailing list