[cairo] offset drawing in a surface
spitzak at gmail.com
Wed Jan 4 12:28:07 PST 2012
swati upadhyaya wrote:
> Hi Henry and Andrea,
> First of all thanks for reply
> I didn't get what you people mentioned
> as I am new to cairo lib . 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
> 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..
You want to do cairo_translate(cr, -100, -100)
Then the point 100,100 will be in the top-left of your image.
More information about the cairo