[cairo] White seams (lines) appearing between objects

Kristof Van Landschoot kristof at coin-c.com
Mon Jan 14 07:03:19 PST 2008


Hi,

We've isolated a problem where we seem to get white seams between two  
objects that really shouldn't have them.  A black rectangle and a red  
image should touch seamlessly, but using these parameters for  
transformation matrix and image size they do generate a pixel-wide  
white line between them.

Is there anything we can do about this?

The attached sample code generates the white vertical line between  
where the right side of the black rectangle touches the left side of  
the red image, at 799.52 along the x-axis in userspace coordinates.

We're using cairo 1.4.10.

Any help is much appreciated.

Thanks,
Kristof


> // image of 444 x 608, ARGB
> cairo_surface_t *lCairoSurface = cairo_image_surface_create 
> (CAIRO_FORMAT_ARGB32,444,608);
> unsigned char *lBuffer1 = cairo_image_surface_get_data(lCairoSurface);
> memset(lBuffer1,255,444*608*4);
>
> // turn off antialiasing
> cairo_t *lCairoState = cairo_create(lCairoSurface);
> cairo_set_antialias(lCairoState,CAIRO_ANTIALIAS_NONE);
>
> // this transformation seems to be necessary
> cairo_matrix_t lFitInImageMatrix;
> cairo_matrix_init(&lFitInImageMatrix, 
> 0.49908064092,0,0,0.49908064092,-0.07092198377,0);
> cairo_transform(lCairoState,&lFitInImageMatrix);
>
> // draw the black rectangle
> cairo_move_to(lCairoState, 48, 497.6);
> cairo_line_to(lCairoState, 799.52, 497.6);	// right side at 799.52!
> cairo_line_to(lCairoState, 799.52, 513.44);
> cairo_line_to(lCairoState, 48, 513.44);
> cairo_close_path(lCairoState);	
> cairo_set_source_rgba(lCairoState, 0, 0, 0, 255);
> cairo_fill(lCairoState);
>
> // create a red image of 30 by 160 pixels, 4 bytes wide (ARGB)
> int i = 0;
> unsigned char *lImage = new unsigned char[30*160*4];
> for (; i<30*160*4; )
> {
> 	lImage[i++] = 255; lImage[i++] = 0; lImage[i++] = 0; lImage[i++] =  
> 255;
> }
>
> // and draw it
> cairo_surface_t *lSurface = cairo_image_surface_create_for_data(	 
> lImage,
> 							CAIRO_FORMAT_ARGB32, 30, 160, 30*4 );
> cairo_matrix_t lMatrix;
> cairo_matrix_init_identity(&lMatrix);
> lMatrix.x0 += 799.52;					// right next to the black rectangle!
> lMatrix.y0 += 464.32;
> cairo_transform(lCairoState,&lMatrix);
> cairo_set_source_surface(lCairoState,lSurface,0,0);
> cairo_paint(lCairoState);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080114/9bf3dcf3/attachment.html 


More information about the cairo mailing list