[cairo] Regarding Line Drwing

swati upadhyaya swatiupadhyaya at gmail.com
Wed Jan 4 08:37:16 PST 2012


I have a problem with free hand line drawing using cairo
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    *surface =
cairo_image_surface_create_for _data(unsigned char
where width is image width = 200
height is image height = 200.
Then I am doing
*cr = cairo_create(surface);*

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
1) what can I do to shift the origin of the surface fom 0 to 100 ? So that
it will draw on the same..
 I am using elementary API(like evas,efl). And on mouse move callback I am
drawing the line...
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.

First time I am using cairo lib thats why not familiar of everything.
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.

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)...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120104/2f6fd75a/attachment.htm>

More information about the cairo mailing list