[cairo] Output of physical resolution of bitmap images

Uli Schlachter psychon at znc.in
Sat Feb 18 10:13:02 UTC 2017


On 18.02.2017 06:37, Henner Zeller wrote:
> Anyway - it looks like there is no way to set the resolution on a
> cairo_surface_t which then would be written out in a png-header when
> calling cairo_surface_write_to_png().
> 
> Cairo never sets the resolution when writing the PNG (which would be a
> call to png_set_pHYs()).
> 
> This is a real limitation, because it means you can't create a
> high-resolution image of something and have the receiver of the image
> know exactly the size of the artwork.

You are not meant to create "real" PNGs with cairo. To quote the
documentation:

> It is a toy API. It only offers very simple support for reading and
> writing PNG files, which is sufficient for testing and demonstration
> purposes. Applications which need more control over the generated PNG
> file should access the pixel data directly, using
> cairo_image_surface_get_data() or a backend-specific access function,
> and process it with another library, e.g. gdk-pixbuf or libpng.
https://www.cairographics.org/manual/cairo-PNG-Support.html

Sorry,
Uli
-- 
- Captain, I think I should tell you I've never
  actually landed a starship before.
- That's all right, Lieutenant, neither have I.


More information about the cairo mailing list