[cairo] surface_create and pnm

Simon Sapin simon.sapin at exyr.org
Tue Dec 25 03:39:38 PST 2012


Le 25/12/2012 11:36, Gadi Dor a écrit :
> I have some code that read .pnm file with fgets and had it into buffer,

Hi,

I’d say the easy way would be to use pnmtopng or a similar tool, then 
use cairo_image_surface_create_from_png() or 
cairo_image_surface_create_from_png_stream().

A (maybe) more efficient way would be to parse the source image with 
libnetpbm, create a cairo image surface of the right size, then copy the 
pixels to a buffer returned by cairo_image_surface_get_data() while 
converting them to cairo’s native-endian ARGB32 format.

Cheers,
-- 
Simon Sapin


More information about the cairo mailing list