[cairo] Trouble resizing (scaling) an XImage
Uli Schlachter
psychon at znc.in
Mon Jun 27 10:59:16 PDT 2011
On 27.06.2011 17:00, Justin Anderson wrote:
> //Create a simple X11 window for displaying the XImage...
> window = XCreateSimpleWindow(
> display,
> RootWindowOfScreen(screen),
> 0, // x
> 0, // y
> width,
> height,
> 0, // border width
> BlackPixelOfScreen(screen), // border
> BlackPixelOfScreen(screen) // background
> );
> XMapRaised(display, window);
I hope you are waiting for an Expose event before actually trying to draw
something? (Or alternatively you aren't running any window manager)
> //cairo stuff...
> cairo_surface_t *surface_dest = cairo_xlib_surface_create(display,
> window, XDefaultVisualOfScreen(screen), width, height);
> cairo_t *cr_dest = cairo_create(surface_dest);
>
> cairo_surface_t *surface_source =
> cairo_image_surface_create_for_data((unsigned char*)(xImage->data),
> CAIRO_FORMAT_RGB24, xImage->width, xImage->height, xImage->bytes_per_line);
In another mail you said:
> I should mention that the source image is an 8 bit grayscale. Thanks.
So where is CAIRO_FORMAT_RGB24 coming from?
> cairo_scale(cr_dest, width / xImage->width, height / xImage->height);
>
> cairo_set_source_surface(cr_dest, surface_source, 0, 0);
> cairo_paint(cr_dest);
> cairo_surface_destroy(surface_source);
>
> //Put the scaled XImage on the window...
> XPutImage(display, window, gc, xImage, 0, 0, 0, 0, width, height);
Where is this coming from? You are first drawing something with cairo and then
using XPutImage() to "overwrite" the result?
> cairo_surface_destroy(surface_dest);
> cairo_surface_destroy(surface_source);
--
- Buck, when, exactly, did you lose your mind?
- Three months ago. I woke up one morning married to a pineapple.
An ugly pineapple... But I loved her.
More information about the cairo
mailing list