[cairo] CAIROMM: surfaces
cworth at cworth.org
Thu Jan 12 11:23:41 PST 2006
On Wed, 11 Jan 2006 16:05:47 -0600, Jonathon Jongsma wrote:
> > How is an xlib surface different than an Image surface?
By and large, once you have a surface, they are all the same. You can
pass any surface to cairo_create to draw to it, you can write the
results of any surface out to an image file with
The only big difference in the various surface types is the create
functions, which in C all differ in name (obviously) and in many cases
differ in the arguments (also quite obviously).
> Why isn't there a cairo_platform_surface_create()?
Most of the current surface_create functions assume that you first do
_something_ to create a backend-specific object of some type,
(XCreateWindow, fopen, malloc, etc.) and you pass the result of that
to surface_create. So in C, there is no way to do a generic
cairo_platform_surface_create that could accept the variety of
different arguments in a type-safe way.
If it made sense to do something different in a language-binding, and
the language-binding guidelines don't recommend that, then what we
should discuss here is a possible modification to those guideline.
> That's one thing that I'm kind of unclear about. The cairo manual
> says image surfaces are just 'memory buffers" or a "bitmap image in
Yes. And in particular, you may create an image surface for your own
chunk of memory (the _with_data variant), so you are free to examine
the results at any point and do whatever you want with them, (with the
note that you should let cairo know via mark_dirty if you modify
anything and later want to continue to draw to the surface with
> I know that image surfaces can be saved as .png files if
> libpng is installed,
Actually, that will work with any type of cairo surface (if libpng is
installed). The implementation may involve cairo creating a temporary
image surface and copying in order to achieve this, but that is
transparent to the caller of cairo_surface_write_png.
> but I don't know if there's any way to display
> them onscreen easily (or at all).
See above regarding doing whatever you want with your own memory
> I'm also not clear whether they're
> meant to be a base 'class' for the other surfaces or whether they're
> something else entirely.
They are something else entirely, not a "base class". The "base class"
would be cairo_surface_t, not cairo_image_surface_t.
> For example, is
> cairo_image_surface_get_width() supposed to be valid to call on an
It would be an error to call that. It's only valid to call
cairo_image_surface_* on a surface created with
cairo_image_surface_create_*, (and similarly for any other
cairo_<foo>_surface_* functions---though we do try to limit the number
of such functions that exist).
> The documentation is pretty sparse on this. Can one of
> the cairo developers help clarify this a bit??
Yeah, sorry about that. I hope this answer helps somewhat.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060112/d40e4bfb/attachment.pgp
More information about the cairo