[cairo] Smoother Scaling
Tim Corio
tcorio at rochester.rr.com
Mon Dec 13 10:12:15 PST 2010
I'm scaling an image. The result looks grainy and there are
unacceptable artifacts in fine parallel lines making the output look
more like a tight hatch pattern.
I've tried using cairo_pattern_set_filter in the snippet below. I've
used all the filters and see no difference in the output image.
Is there some other way to specify how scaling is performed to get a
better quality image?
Thanks,
Tim
outImage->surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
inDestWidth,
inDestHeight);
cr = cairo_create (outImage->surface);
/* Draw background. */
cairo_set_source_rgb (cr, red, green, blue);
cairo_rectangle (cr, 0, 0, inDestWidth, inDestHeight);
cairo_fill (cr);
cairo_scale (cr, scale, scale);
cairo_translate (cr, -trx, -try);
cairo_rotate (cr, inRotation * (M_PI / 180.0));
cairo_translate (cr, trx, try);
cairo_set_source_surface (cr,
inImage->surface,
-shape_rectangle_get_left(inCropRegion),
-shape_rectangle_get_top(inCropRegion));
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BEST);
cairo_rectangle (cr,
0,
0,
shape_rectangle_get_width(inCropRegion),
shape_rectangle_get_height(inCropRegion));
cairo_fill (cr);
cairo_destroy (cr);
More information about the cairo
mailing list