Hi Henry and Andrea,<div><br></div><div>First of all thanks for reply <img src="cid:gtalk.338@goomoji.gmail" style="margin-top: 0px; margin-right: 0.2ex; margin-bottom: 0px; margin-left: 0.2ex; vertical-align: middle; " goomoji="gtalk.338"><br>
<div>                                 </div><div>                                  I didn&#39;t get what you people mentioned as I am new to cairo lib <img src="cid:gtalk.323@goomoji.gmail" style="margin-top: 0px; margin-right: 0.2ex; margin-bottom: 0px; margin-left: 0.2ex; vertical-align: middle; " goomoji="gtalk.323">. Let me explain my problem briefly, Suppose I have a device with screen width and height as 400 x 400. And I have an image with 200 x 200. Now in my device for this image start of x=100 and end of x = 300. Now I have to draw the line from 100 to 300..I am using the API</div>
<div>surface = cairo_image_surface_create_for _data(unsigned char *buff,CAIRO_FORMAT_ARGB32,width,height,cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,width))</div><div>where width is image width = 200</div><div>height is image height = 200.</div>
<div>Then I am doing </div><div>cr = cairo_create(surface);</div><div><br></div><div>Now the problem is as the surface starts from top left only so it will go from 0 to 200 but I want to draw form 100 to 300. So</div><div>
1) what can I do to shift the origin of the surface fom 0 to 100 ? So that it will draw on the same..</div><div> I am using elementary API(like evas,efl). And on mouse move callback I am drawing the line...</div><div>2) I have tried giving whole the width and height as my devise that is width = height = 400. But in this case while saving the image some scaling factor occur and line drawn become thin and position is also shifted. This is because we are capturing 400 x 400 to 200 x 200 image.</div>
<div><br></div><div>First time I am using cairo lib thats why not familiar of everything.</div><div>for the image with the width and height same as screen its working fine..as for that surface as well as image both starts from 0.</div>
<div><br></div><div><br></div><div>Please let me know how to solve this problem(how to shift the origin of the surface so that I can draw exactly from where I want to draw)...</div><div><br></div><div><br></div><div> </div>
<div><br><div class="gmail_quote">On Wed, Jan 4, 2012 at 2:13 PM, Andrea Canciani <span dir="ltr">&lt;<a href="mailto:ranma42@gmail.com">ranma42@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wed, Jan 4, 2012 at 1:56 AM, Henry (Yu) Song - SISA<br>
&lt;<a href="mailto:hsong@sisa.samsung.com">hsong@sisa.samsung.com</a>&gt; wrote:<br>
&gt; Date:   Fri Dec 30 11:24:54 2011 -0800<br>
&gt;<br>
&gt;    gl: Add support to invert non texture gl surface image that does not have<br>
&gt;    GL_MESA_pack_invert when map from gl surface to image surface<br>
&gt;<br>
&gt; diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c<br>
&gt; index 8f69033..8b8f196 100644<br>
&gt;<br>
&gt; --- a/src/cairo-gl-surface.c<br>
&gt; +++ b/src/cairo-gl-surface.c<br>
&gt; @@ -1001,6 +1001,10 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,<br>
&gt;     unsigned int cpp;<br>
&gt;     cairo_bool_t invert;<br>
&gt;     cairo_status_t status;<br>
&gt; +    cairo_t *inv_cr = NULL;<br>
&gt; +    cairo_image_surface_t *inv_image = NULL;<br>
&gt; +    cairo_pattern_t *inv_pattern = NULL;<br>
&gt; +    cairo_matrix_t inv_matrix;<br>
&gt;<br>
&gt;     /* Want to use a switch statement here but the compiler gets whiny. */<br>
&gt;     if (surface-&gt;base.content == CAIRO_CONTENT_COLOR_ALPHA) {<br>
&gt; @@ -1093,6 +1097,50 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,<br>
&gt;        image = (cairo_image_surface_t *)<br>
&gt;            _cairo_surface_create_in_error (status);<br>
&gt;     }<br>
&gt; +<br>
&gt; +    /*<br>
&gt; +     * FIXME: we must invert the image if it is non texture surface,<br>
&gt; +     * and it does not have GL_MESA_pack_invert.<br>
&gt; +     * Is there more efficient way to invert image?<br>
<br>
</div></div>Using negative stride might be more efficient, but some backends might<br>
not (yet) support them correctly.<br>
<br>
Side note:<br>
It is already possible to create negative stride images.<br>
Should we add a test trying to use them and support them?<br>
Unless I get feedback, I&#39;ll try to write the test this weekend.<br>
<div><div class="h5"><br>
&gt; +     */<br>
&gt; +<br>
&gt; +    if (! _cairo_gl_surface_is_texture (surface) &amp;&amp; ! invert) {<br>
&gt; +        inv_image = (cairo_image_surface_t*)<br>
&gt; +       _cairo_image_surface_create_with_pixman_format (NULL,<br>
&gt; +                                                       pixman_format,<br>
&gt; +                                                       extents-&gt;width,<br>
&gt; +                                                       extents-&gt;height,<br>
&gt; +                                                       -1);<br>
&gt; +       if (unlikely (inv_image-&gt;base.status)) {<br>
&gt; +           goto CLEAR_IMAGE;<br>
&gt; +       }<br>
&gt; +<br>
&gt; +       image-&gt;base.is_clear = FALSE;<br>
&gt; +       inv_pattern = cairo_pattern_create_for_surface (&amp;image-&gt;base);<br>
&gt; +       if (unlikely (inv_pattern-&gt;status)) {<br>
&gt; +           goto CLEAR_PATTERN;<br>
&gt; +       }<br>
&gt; +       cairo_matrix_init_scale (&amp;inv_matrix, 1.0, -1.0);<br>
&gt; +       cairo_matrix_translate (&amp;inv_matrix, 0, -(extents-&gt;height));<br>
&gt; +       cairo_pattern_set_matrix (inv_pattern, &amp;inv_matrix);<br>
&gt; +<br>
&gt; +       inv_cr = cairo_create (&amp;inv_image-&gt;base);<br>
&gt; +       if (unlikely (inv_cr-&gt;status)) {<br>
&gt; +           goto CLEAR_CAIRO;<br>
&gt; +       }<br>
&gt; +       cairo_set_source (inv_cr, inv_pattern);<br>
&gt; +       cairo_set_operator (inv_cr, CAIRO_OPERATOR_SOURCE);<br>
&gt; +       cairo_paint (inv_cr);<br>
<br>
</div></div>You&#39;re using the same surface as source and as destination.<br>
This results in undefined behavior.<br>
If you want to flip the image like this, you should use two independent surfaces<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
&gt; +       cairo_surface_destroy (&amp;image-&gt;base);<br>
&gt; +       image = (cairo_image_surface_t *)cairo_surface_reference (&amp;inv_image-&gt;base);<br>
&gt; +    }<br>
&gt; +<br>
&gt; +CLEAR_CAIRO:<br>
&gt; +    cairo_destroy (inv_cr);<br>
&gt; +CLEAR_PATTERN:<br>
&gt; +    cairo_pattern_destroy (inv_pattern);<br>
&gt; +CLEAR_IMAGE:<br>
&gt; +    cairo_surface_destroy (&amp;inv_image-&gt;base);<br>
&gt;<br>
&gt;     return &amp;image-&gt;base;<br>
&gt;  }<br>
&gt; --<br>
&gt; cairo mailing list<br>
&gt; <a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
&gt; <a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><font color="#000099" face="&#39;times new roman&#39;, serif" size="4"><i><br></i></font>
</div></div>