[cairo] Regarding saving a image surface as PNG

Chris Wilson chris at chris-wilson.co.uk
Thu Apr 17 06:09:29 PDT 2008


On Thu, 2008-04-17 at 18:24 +0530, Chandra Shekhar Sengupta wrote:
> Hi ,
> i have tried with adding "get_target" in all possible places, but
> still "write_png" is saving zero byte png.i have attched the full
> code . Could you tell how to save that surface?

Compiled and ran your example - it generated 'sticker.png' flawlessly.

> if(cairo_surface_status(tsurf) != CAIRO_STATUS_SUCCESS)
>  g_print(" nil surface \n");
> else
>  cairo_surface_write_to_png (tsurf, "sticker.png");

I'd suggest replacing this section to check the status return from
cairo_surface_write_to_png(), i.e.
	status = cairo_surface_write_to_png (tsurf, "sticker.png");
	if (status) {
		g_print ("Failed to write \"%s\": %s\n",
		         "sticker.png",
		         cairo_status_to_string (status));
	}

However, I would first check the permissions on 'sticker.png'.

-- 
Chris Wilson



More information about the cairo mailing list