[cairo] Correct bitmap size and offset calculation based of pen width and scale

Kozhevnikov Mikhail mikhailkozhevnikov at yandex.ru
Mon Sep 20 05:38:51 PDT 2010

Hi Prashant,

cairo_stroke_extents returns the bounding box for the image based on the pen width etc. Should work fine for centering.
It doesn't seem like a good idea to calculate the offset manually.


17.09.2010, 14:02, "Prashant Saxena" <animator333 at yahoo.com>:
> Hi,
> In this simple script I am trying to render an offline image and save it as
> bitmap.
> This is a test to calculate the correct size of bitmap when you have different
> pen widths (odd & even)
> and different scale.
> I think bitmap size calculation is done correctly but there is problem while
> specifying the offset before you
> draw anything on bitmap.
> The script will generate two bitmaps using wx.GraphicsContext and Cairo. In both
> the images you can see the drawing
> is not exactly in center.
> Question : How do calculate offset based on pen width and scale?
> Cheers
> Prashant
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list