Resize image without using cairo_surface_set_device_scale

Viewed 107

In old cairo-1.8.8-3.1, under C in linux clone of RHEL 6.4, I need to implement a function that performs the same operations as

void
cairo_surface_set_device_scale (cairo_surface_t *surface,
                                double x_scale,
                                double y_scale);

as this function is not available, how can I do ?

Update: In the Cairo Mailing Lists I found the following function that does the job :

cairo_surface_t *scale_to_half(cairo_surface_t *s, int orig_width, int
orig_height,  double x_scale, double y_scale)
{
   cairo_surface_t *result = cairo_surface_create_similar(s,
        cairo_surface_get_content(s), orig_width*x_scale, orig_height*y_scale);
   cairo_t *cr = cairo_create(result);
   cairo_scale(cr, x_scale, y_scale);
   cairo_set_source_surface(cr, s, 0, 0);
   cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
   cairo_paint(cr);
   cairo_destroy(cr);
   return result;
}

but the quality is very low compared to cairo_surface_set_device_scale.

0 Answers
Related