[cairo] cairo_surface_write_to_png & out of memory return status‏

Pablo Romero romero619 at hotmail.com
Wed Feb 4 09:22:25 PST 2009

I need help debugging the "out of memory" error Im receiving when trying to call the cairo_surface_write_to_png function.
Im sure that the system does have plenty of memory.
The function is being called from within a larger program, so Im not sure if the main program is limiting its memory use somehow (Im not a very experienced C programmer).
How much memory is needed for the "write_to_png" operation?
Is there a way to pre-allocate this memory needed for the "write_to_png"?
How can I debug what is causing the "no memory" error in this function???
both the cairo_t and cairo_surface_t functions are returning "success" statuses; only the "write_to_png" operation is failing...
the png file Im trying to create is very basic:
//both of these two operations succeed, returning 'success' status
 cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
 sprintf(pout,"surface status: %s\n",cairo_status_to_string(cairo_surface_status(surface)));
 cairo_t *cr = cairo_create (surface);
 sprintf(pout,"cairo status: %s\n",cairo_status_to_string(cairo_status(cr)));
//very simple, just paint canvas blue
 cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
//this operation fails, returns an 'out of memory' status
 cairo_status_t x = cairo_surface_write_to_png (surface, "snow1.png");

 cairo_surface_destroy (surface);
 sprintf(pout,"write png status: %s\n",cairo_status_to_string(x));
If I compile this code individually, it works fine.
If I try to compile within my larger program, I receive the 'out of memory' status, even though Im sure there is plenty of memory in the system...
please help.
Windows Live™: E-mail. Chat. Share. Get more ways to connect. 

More information about the cairo mailing list