[cairo] cairo_surface_write_to_png and 32-bit visuals in 1.10.0

Ross Alexander Ross.Alexander at EU.NEC.COM
Tue Sep 28 02:36:09 PDT 2010

Background: I was tired of using xwd, especially as it does not support RGBA 32 bit visuals.  I hacked together a program from the latest xwininfo (based on XCB) to get the Window ID using a pointer selection and then created a surface based on that ID.

#ifdef XLIB
  cairo_surface_t *surface = cairo_xlib_surface_create(dpy, target_win, vinfos[0].visual, geom->width, geom->height);
  cairo_surface_t *surface = cairo_xcb_surface_create(conn, target_win, v, geom->width, geom->height);
  cairo_surface_write_to_png(surface, file);

This works fine for 24-bit visual windows but with 32-bit visuals (eg gnome-terminal) I get the following error.

xwd: cairo-xcb-surface.c:504: _get_image: Assertion `reply->depth == surface->depth' failed.

Using xlib on 32-bit visuals doesn’t fail but instead produces a zero sized PNG file.

I understand this may be an abuse of cairo for which it wasn’t designed and I maybe should use XImage or Xrender (I haven’t actually looked at render for image transfers) but as cairo has most of this code already I was hoping for some pointers.

Many thanks


Ross Alexander
SAP Basis
NEC Europe Ltd
European Information Systems
Tel:     +44 20 8752 3394

IMPORTANT: The information contained in this e-mail and attachment (if any) is intended for the person to whom it is addressed and may contain confidential and/or privileged information. The contents of this message may contain personal views which are not the views of NEC Europe Ltd or its subsidiaries, unless specifically stated. You should not copy, retain, forward or disclose its contents to anyone else, or take any action based upon it, if it is not addressed to you personally.  If you have received this e-mail in error please contact the sender immediately. Any legally binding agreement resulting from its content must be made separately in a printed

NEC Europe Limited | Registered Office: NEC House, 1 Victoria Road, London W3 6BL | Registered in England 2832014

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100928/230aec26/attachment.html>

More information about the cairo mailing list