[cairo] Paint from a surface to other doesn't work?

Carlos López González genetita at gmail.com
Sun Mar 24 03:04:25 PDT 2013


Oh dear, everyone must read carefully the Cairo manual!
The requested flush and mark_dirty commands form the documentation were
included in my code in a conditional statement  what was not really
executed in most of the cases!
Now, once fixed the direct pixel manipulation functions everything works
like a charm! ^__^
Thanks for reading anyway!
Cheers!


2013/3/21 Carlos López González <genetita at gmail.com>

> Hi!
> I'm absolutely getting crazy and I need someone that give me a clue on
> this:
>
> In this section of code:
>
> void studio::Widget_NavView::on_finish_render()
>
> {
>
> if(studio::App::navigator_uses_cairo)
>
> {
>
> if(!cairo_surface)
>
> {
>
> synfig::warning("dock_navigator: Bad cairo surface");
>
> return;
>
> }
>
>  if(cairo_surface_status(cairo_surface))
>
> return;
>
>  Target_Cairo::gamma_filter(cairo_surface);
>
>
>  int w = 0, h = 0;
>
> int dw = cairo_image_surface_get_width(cairo_surface);
>
> int dh = cairo_image_surface_get_height(cairo_surface);
>
>
>  if(cairo_prev)
>
> {
>
> w = cairo_image_surface_get_width(cairo_prev);
>
> h = cairo_image_surface_get_height(cairo_prev);
>
> }
>
>
>  if( w!=dw || h!=dh || !cairo_prev)
>
> {
>
> cairo_prev=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dw, dh);
>
> }
>
> synfig::info("cairo_surface is mapped %d",
> cairo_surface_is_mapped(cairo_surface)); // is not mapped
>
> static int pass2=0;
>
> // Image written to file is correct
>
> cairo_surface_write_to_png(cairo_surface, strprintf(
> "dock_navigator_on_finish_render_cairo_surface-pass%d.png",
> pass2).c_str());
>
>
>  cairo_t* cr=cairo_create(cairo_prev);
>
> cairo_save(cr);
>
> cairo_set_source_surface(cr, cairo_surface, 0, 0);
>
> cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
>
> cairo_paint(cr);
>
> cairo_restore(cr);
>
> cairo_destroy(cr);
>
>
>  cairo_surface_write_to_png(cairo_prev, strprintf(
> "dock_navigator_on_finish_render_cairo_prev-pass%d.png", pass2).c_str());
>
> pass2++;
>
> }
>
> }
>
>
>
> the written to file images cairo_prev and cairo_surface doesn't coincide,
> how's that possible???
> In particular cairo_surface is correct (what I expect to be) and
> cairo_prev is simply transparent.
> If I can write a surface to png correctly, why I can't paint it to other
> surface??
> Thanks in advance!
>
> --
> Carlos
> http://synfig.org
>



-- 
Carlos
http://synfig.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130324/9ca724fb/attachment.html>


More information about the cairo mailing list