[cairo] cairo_surface_write_to_png and 32-bit visuals in 1.10.0
Ross Alexander
Ross.Alexander at EU.NEC.COM
Wed Oct 6 01:28:13 PDT 2010
After looking at this problem some more, specially in the setup of XCB surfaces I noticed if cairo is passed a 32bit visual it effectively assumes it is 24bit by setting alpha_masks = 0 before getting the pixman format, resulting in a 24 bit x8r8g8b8 format. It then gets the xrender format which is a 32bit format but there doesn't seem to be a simple way of getting from the xrender format back to the correct pixman format. I've just hacked a simple chance which works may well not be the way forward.
*** cairo-xcb-surface.c.orig 2010-10-06 09:13:36.000000000 +0100
--- cairo-xcb-surface.c 2010-10-06 09:14:30.000000000 +0100
***************
*** 1179,1184 ****
--- 1179,1186 ----
image_masks.red_mask = visual->red_mask;
image_masks.green_mask = visual->green_mask;
image_masks.blue_mask = visual->blue_mask;
+ if (depth == 32)
+ image_masks.alpha_mask = 0xffffffff & (~visual->red_mask) & (~visual->green_mask) & (~visual->blue_mask);
if (depth > 16)
image_masks.bpp = 32;
else if (depth > 8)
Cheers,
Ross
>
> #ifdef XLIB
> cairo_surface_t *surface = cairo_xlib_surface_create(dpy,
> target_win, vinfos[0].visual, geom->width, geom->height); #else
> cairo_surface_t *surface = cairo_xcb_surface_create(conn,
> target_win, v, geom->width, geom->height); #endif
> free(geom);
> 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.
--
Chris Wilson, Intel Open Source Technology Centre
Click https://www.mailcontrol.com/sr/yrARTltOOmfTndxI!oX7UhdcvSFje8hNh1+ulZdIXKwchpRVtzoOTbmj5KHvHT3EGLELryxzq6ni5jK2rp2Ftw== to report this email as spam.
--
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list