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'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"><<a href="mailto:ranma42@gmail.com">ranma42@gmail.com</a>></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>
<<a href="mailto:hsong@sisa.samsung.com">hsong@sisa.samsung.com</a>> wrote:<br>
> Date: Fri Dec 30 11:24:54 2011 -0800<br>
><br>
> gl: Add support to invert non texture gl surface image that does not have<br>
> GL_MESA_pack_invert when map from gl surface to image surface<br>
><br>
> diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c<br>
> index 8f69033..8b8f196 100644<br>
><br>
> --- a/src/cairo-gl-surface.c<br>
> +++ b/src/cairo-gl-surface.c<br>
> @@ -1001,6 +1001,10 @@ _cairo_gl_surface_map_to_image (void *abstract_surface,<br>
> unsigned int cpp;<br>
> cairo_bool_t invert;<br>
> cairo_status_t status;<br>
> + cairo_t *inv_cr = NULL;<br>
> + cairo_image_surface_t *inv_image = NULL;<br>
> + cairo_pattern_t *inv_pattern = NULL;<br>
> + cairo_matrix_t inv_matrix;<br>
><br>
> /* Want to use a switch statement here but the compiler gets whiny. */<br>
> if (surface->base.content == CAIRO_CONTENT_COLOR_ALPHA) {<br>
> @@ -1093,6 +1097,50 @@ _cairo_gl_surface_map_to_image (void *abstract_surface,<br>
> image = (cairo_image_surface_t *)<br>
> _cairo_surface_create_in_error (status);<br>
> }<br>
> +<br>
> + /*<br>
> + * FIXME: we must invert the image if it is non texture surface,<br>
> + * and it does not have GL_MESA_pack_invert.<br>
> + * 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'll try to write the test this weekend.<br>
<div><div class="h5"><br>
> + */<br>
> +<br>
> + if (! _cairo_gl_surface_is_texture (surface) && ! invert) {<br>
> + inv_image = (cairo_image_surface_t*)<br>
> + _cairo_image_surface_create_with_pixman_format (NULL,<br>
> + pixman_format,<br>
> + extents->width,<br>
> + extents->height,<br>
> + -1);<br>
> + if (unlikely (inv_image->base.status)) {<br>
> + goto CLEAR_IMAGE;<br>
> + }<br>
> +<br>
> + image->base.is_clear = FALSE;<br>
> + inv_pattern = cairo_pattern_create_for_surface (&image->base);<br>
> + if (unlikely (inv_pattern->status)) {<br>
> + goto CLEAR_PATTERN;<br>
> + }<br>
> + cairo_matrix_init_scale (&inv_matrix, 1.0, -1.0);<br>
> + cairo_matrix_translate (&inv_matrix, 0, -(extents->height));<br>
> + cairo_pattern_set_matrix (inv_pattern, &inv_matrix);<br>
> +<br>
> + inv_cr = cairo_create (&inv_image->base);<br>
> + if (unlikely (inv_cr->status)) {<br>
> + goto CLEAR_CAIRO;<br>
> + }<br>
> + cairo_set_source (inv_cr, inv_pattern);<br>
> + cairo_set_operator (inv_cr, CAIRO_OPERATOR_SOURCE);<br>
> + cairo_paint (inv_cr);<br>
<br>
</div></div>You'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>
> + cairo_surface_destroy (&image->base);<br>
> + image = (cairo_image_surface_t *)cairo_surface_reference (&inv_image->base);<br>
> + }<br>
> +<br>
> +CLEAR_CAIRO:<br>
> + cairo_destroy (inv_cr);<br>
> +CLEAR_PATTERN:<br>
> + cairo_pattern_destroy (inv_pattern);<br>
> +CLEAR_IMAGE:<br>
> + cairo_surface_destroy (&inv_image->base);<br>
><br>
> return &image->base;<br>
> }<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>
--<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="'times new roman', serif" size="4"><i><br></i></font>
</div></div>