<div dir="ltr">Oh dear, everyone must read carefully the Cairo manual!<div style>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!</div>
<div style>Now, once fixed the direct pixel manipulation functions everything works like a charm! ^__^</div><div style>Thanks for reading anyway!</div><div style>Cheers!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/3/21 Carlos López González <span dir="ltr"><<a href="mailto:genetita@gmail.com" target="_blank">genetita@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi!<div>I'm absolutely getting crazy and I need someone that give me a clue on this:</div><div><br></div><div>In this section of code:</div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">

<span style="color:rgb(187,44,162)">void</span> studio::Widget_NavView::on_finish_render()</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">      </span><span style="color:rgb(187,44,162)">if</span>(studio::App::navigator_uses_cairo)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">      </span>{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">if</span>(!cairo_surface)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(209,47,27)"><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">                  </span>synfig::warning(</span>"dock_navigator: Bad cairo surface"<span style="color:rgb(0,0,0)">);</span></p>


<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(187,44,162)"><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">                 </span></span>return<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>}</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="white-space:pre-wrap">              </span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">if</span>(cairo_surface_status(cairo_surface))</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(187,44,162)"><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">                 </span></span>return<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="white-space:pre-wrap">              </span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>Target_Cairo::gamma_filter(cairo_surface);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">int</span> w = <span style="color:rgb(39,42,216)">0</span>, h = <span style="color:rgb(39,42,216)">0</span>;</p>


<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">int</span> dw = cairo_image_surface_get_width(cairo_surface);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">int</span> dh = cairo_image_surface_get_height(cairo_surface);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">if</span>(cairo_prev)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">                      </span>w = cairo_image_surface_get_width(cairo_prev);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">                      </span>h = cairo_image_surface_get_height(cairo_prev);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>}</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">if</span>( w!=dw || h!=dh || !cairo_prev)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">                      </span>cairo_prev=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dw, dh);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>}</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>synfig::info(<span style="color:rgb(209,47,27)">"cairo_surface is mapped %d"</span>, cairo_surface_is_mapped(cairo_surface)); <span style="color:rgb(0,132,0)">// is not mapped</span></p>


<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span><span style="color:rgb(187,44,162)">static</span> <span style="color:rgb(187,44,162)">int</span> pass2=<span style="color:rgb(39,42,216)">0</span>;</p>


<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">            </span></span>// Image written to file is correct</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_surface_write_to_png(cairo_surface, strprintf(<span style="color:rgb(209,47,27)">"dock_navigator_on_finish_render_cairo_surface-pass%d.png"</span>, pass2).c_str());</p>


<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_t* cr=cairo_create(cairo_prev);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_save(cr);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_set_source_surface(cr, cairo_surface, <span style="color:rgb(39,42,216)">0</span>, <span style="color:rgb(39,42,216)">0</span>);</p>


<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_paint(cr);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_restore(cr);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_destroy(cr);<br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>cairo_surface_write_to_png(cairo_prev, strprintf(<span style="color:rgb(209,47,27)">"dock_navigator_on_finish_render_cairo_prev-pass%d.png"</span>, pass2).c_str());</p>


<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>pass2++;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">      </span>}</p><p style="margin:0px;font-size:11px;font-family:Menlo">}</p><p style="margin:0px;font-size:11px;font-family:Menlo">
<br></p><p style="margin:0px;font-size:11px;font-family:Menlo"> <br></p><div><div>the written to file images cairo_prev and cairo_surface doesn't coincide, how's that possible???</div><div>In particular cairo_surface is correct (what I expect to be) and cairo_prev is simply transparent.</div>

<div>If I can write a surface to png correctly, why I can't paint it to other surface??</div><div>Thanks in advance!</div></div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>Carlos<br><a href="http://synfig.org" target="_blank">http://synfig.org</a><br>


</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Carlos<br><a href="http://synfig.org" target="_blank">http://synfig.org</a><br>
</div>