[cairo] question about cairo use : cairo_scale

Emmanuel Schaer dirigeance at free.fr
Fri Aug 3 08:27:40 PDT 2007


Hello,
I try to scale a surface and to copy it to another surface, but there is
no scaling: I think I've forgotten something. I studied several examples
on the web...Would you help me please ?
My test code:
-------------
#include <cairo.h>

int main (int argc,char *argv[]){ //I want to scale the logo from
100*100 to 200*200 (zoom*2)

cairo_surface_t *main,*logo;
cairo_t *main_cr,*logo_cr;

//the main surface, 200*200
main=cairo_image_surface_create(CAIRO_FORMAT_ARGB32,2000,2000);
main_cr=cairo_create(main);

//the logo surface, 100*100
logo=cairo_image_surface_create_from_png
("/home/es/test/recu.png");//dimensions of the logo picture in file are
100*100
logo_cr=cairo_create(logo);

//scaling: logo image 100*100 should become 200*200 // but there is no
change
cairo_scale(logo_cr,2,2);

//copy the logo surface to the main surface
cairo_set_source_surface(main_cr,logo,0,0);
cairo_paint(main_cr);
cairo_destroy(logo_cr);
cairo_surface_destroy(logo);

//end
cairo_destroy(main_cr);
cairo_surface_write_to_png(main,"result.png");
cairo_surface_destroy(main);

return 0;
}
-------------



More information about the cairo mailing list