[cairo] how to scale an image - correction
Kelvin Cheng
KCheng at extracomm.com
Thu Jan 22 02:11:28 PST 2009
Thanks! I will try later.
From:
Bertram Felgenhauer <bertram.felgenhauer at googlemail.com>
To:
cairo at cairographics.org
Date:
21/01/2009 22:55
Subject:
Re: [cairo] how to scale an image - correction
Kelvin Cheng wrote:
> Hi,
> This is a correction to my previous question. The
cairo_matrix_init_scale
> should be 2.0 instead of 0.5.
> Even when it is 2.0, the code still does reduce the image by 50%. Any
> idea ?
Isn't that what you wanted?
> I am trying to scale an image by 50 %.
Try this:
cairo_save(cr);
cairo_translate(cr, target_x, target_y);
cairo_scale(cr, 0.5, 0.5);
// note: it's important to set the source after setting up the
// user space transformation.
cairo_set_source_surface(cr, local_surf, 0, 0);
cairo_paint(cr);
cairo_restore(cr);
> I tried with the following code but it does not work:
>
> cairo_save(cr);
> cairo_set_source_surface(cr, local_surf, target_x, target_y);
>
> // these 2 lines are used for scaling
> cairo_pattern_set_matrix (cairo_get_source(board->cr), &matrix);
What is 'matrix' here?
In any case, the pattern matrix transforms coordinates from user space
to pattern space; multiplying the coordinates by 2 will result in the
appearance of the pattern to shrink to 50% its original size.
HTH,
Bertram
_______________________________________________
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090122/545efc5b/attachment.html
More information about the cairo
mailing list