[cairo] Dimensions of a "surface_t"

Andrea Canciani ranma42 at gmail.com
Tue Nov 8 23:57:46 PST 2011


On Wed, Nov 9, 2011 at 12:32 AM, Charles Doutriaux <doutriaux1 at llnl.gov> wrote:
> Hi,
>
> I'm receiving a cairo_t, I can get the surface via cairo_get_target
>
> Now I would like to know what the dimensions of the "surface" is, if it is
> an image i can use:
>
>    w=cairo_image_surface_get_width(surface);
>    h=cairo_image_surface_get_height(surface);
>
> But I also get surface that ar PS, PDF or SVG
>
> All of these are created with dims:
> e.g.:
>      surface = cairo_ps_surface_create_for_stream(stream_cairo_write,
>                           ws->mf.any->fp,
>                           XW,YW);
>
> Is it possible to retrieve what the original dims/size were?

Something like:

cairo_save (cr);
cairo_reset_clip (cr);
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
cairo_restore (cr);

should give you the size of the surface.
Remember that this will give you the size of the group target, not of
the "original" target.
I believe that to get the size of the original target, you have to
wrap it in a new cairo_t and ask for its clip extents.

Andrea

>
> Thanks,
>
> C.
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list