[cairo] Re: cairo_show_surface (), bug ?

Ravindra rkumar at novell.com
Tue Apr 13 06:20:10 PDT 2004


Hello,

There were some mistakes in the test case I sent earlier. I just
modified cairo-knockout.c demo to demonstrate the problem I have
described below. Hope, it will be easier to just compile and run this
program.

Thanks,
Ravindra

On Tue, 2004-04-13 at 18:15, Ravindra wrote:
> Hi,
> There seems to be a bug in cairo_show_surface API of cairo as mentioned
> in cairo_gstate.c: line 1836 also.
> Below is a testcase to reproduce the possible bug in cairo. This
> function draws an image and its reflection along X-axis side by side.
> The output gets the unwanted space of 1-2 pixels between the image and
> its reflection. Either my approach my wrong or I found a bug in cairo
> ;-).
> Please let me know, if my approach for flipping an image is not correct.
> 
> Thanks,
> Ravindra
> 
> /*======================== CODE ==========================*/
> /* NOTE: Please make sure that image background color and window
> background color are different. */
> 
> /* Provide a surface of the image to be flipped */
> void draw_tile_flipX (cairo_t *ct, cairo_surface_t *original, int width,
> int height)
> {
> 	cairo_surface_t *flip;
> 	cairo_pattern_t *pat;
> 	GpMatrix *matrix = cairo_matrix_create ();
> 
> 	/* clear the repeat flag, if already set */
> 	cairo_surface_set_repeat (original, 0);
> 
> 	/* texture surface to be created */
> 	flip = cairo_surface_create_similar (original,
>                                              CAIRO_FORMAT_ARGB32,
>                                              2 * width, height);
> 
> 	cairo_save (ct);
> 	{
> 		cairo_identity_matrix (ct);
> 
> 		cairo_set_target_surface (ct, flip);
> 		/* Draw original surface */
> 		cairo_show_surface (ct, original, width, height);
> 
> 		/* Draw reflection */
> 		cairo_matrix_translate (matrix, 2 * width, 0);
> 		/* scale in -X direction to flip along X */
> 		cairo_matrix_scale (matrix, -1.0, 1.0);
> 		cairo_surface_set_matrix (original, matrix);
> 		cairo_show_surface (ct, original, width, height);
> 	}
> 	cairo_restore (ct);
> 
> 	cairo_surface_set_repeat (flip, 1);
> 	pat = cairo_pattern_create_for_surface (flip);
> 	cairo_set_pattern (ct, pat);
> 
> 	cairo_matrix_destroy (matrix);
> 	cairo_pattern_destroy (pat);
> 	cairo_surface_destroy (flip);
> }
> 
> void fill_window (cairo_t *ct,  win_t *win)
> {
> 	cairo_save (ct);
> 
> 	cairo_t *surf;
> 	int width, height;
> 	// TODO: create a surface here
> 	draw_tile_flipX (ct, s, width, height);
>         cairo_rectangle (ct, 0, 0, win->width,win->height);
>         cairo_fill (ct);
> 
>         cairo_restore (ct);
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-knockout.c
Type: text/x-c
Size: 10522 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20040413/3e0a97d5/cairo-knockout.bin


More information about the cairo mailing list