[cairo] cairo_set_source_surface questions
唐博
hitiger.2008 at yahoo.com.cn
Tue Feb 14 18:32:09 PST 2012
I want to set the surface to itself and scaled the surface. That is , I want to use just one surface( it has drawed path) to scaled.
I hope you can understand what I mean. This is the simple code. But the result (attachment) is very confused to me. wait fot your reply.
Thank you very much.
#define edge 600
uchar * pbit = (uchar *)malloc(32*edge * edge);
memset(pbit, 0, 32*edge * edge);
surface = cairo_image_surface_create_for_data((uchar *)pbit,
CAIRO_FORMAT_ARGB32,
edge, edge,
cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, edge));
cr = cairo_create(surface);
cairo_set_source_rgba(cr, 1.0, 1.0, 0.0, 1);
cairo_rectangle(cr, 150, 150, 300, 300);
cairo_fill_preserve(cr);
cairo_set_source_rgba(cr, 0.0, 1.0, 1.0, 1);
cairo_stroke(cr);
cairo_move_to(cr, 150, 150);
cairo_line_to(cr, 450, 450);
cairo_line_to(cr, 450, 150);
cairo_line_to(cr, 150, 450);
cairo_stroke(cr);
cairo_save(cr);
cairo_scale(cr, 1.0, 1.4);
cairo_set_source_surface(cr, surface, 0, 0);
cairo_rectangle(cr , 0, 0, edge, edge);
cairo_fill(cr);
cairo_restore(cr);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120215/2d512790/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: question_pic.png
Type: image/png
Size: 170750 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120215/2d512790/attachment-0001.png>
More information about the cairo
mailing list