[cairo] Newbie - simple program doesn't work
Baptiste Gaillard
b_gaillard at hotmail.com
Mon Jul 10 02:34:47 PDT 2006
Hello, I'm begining with cairo with a very simple program that doesn't work, but I don't understand why !!!
Here is the code:
#include <cairo-win32.h>
#define WIDTH 10000
#define HEIGHT 10000
void display_status(cairo_status_t status) {
switch(status) {
case CAIRO_STATUS_SUCCESS:
cout << "CAIRO_STATUS_SUCCESS" << endl;
break;
case CAIRO_STATUS_NULL_POINTER:
cout << "CAIRO_STATUS_NULL_POINTER" << endl;
break;
case CAIRO_STATUS_NO_MEMORY:
cout << "CAIRO_STATUS_NO_MEMORY" << endl;
break;
case CAIRO_STATUS_READ_ERROR:
cout << "CAIRO_STATUS_READ_ERROR" << endl;
break;
case CAIRO_STATUS_INVALID_CONTENT:
cout << "CAIRO_STATUS_INVALID_CONTENT" << endl;
break;
case CAIRO_STATUS_INVALID_FORMAT:
cout << "CAIRO_STATUS_INVALID_FORMAT" << endl;
break;
case CAIRO_STATUS_INVALID_VISUAL:
cout << "CAIRO_STATUS_INVALID_VISUAL" << endl;
break;
}
}
int main(int argc, char** argv) {
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, WIDTH, HEIGHT);
display_status(cairo_surface_status (surface));
cr = cairo_create (surface);
display_status(cairo_surface_status (surface));
cairo_set_source_rgb(cr, 1,1,1);
cairo_fill(cr);
display_status(cairo_surface_status (surface));
cairo_surface_write_to_png (surface, "test.png");
display_status(cairo_surface_status (surface));
cairo_destroy (cr);
cairo_surface_destroy (surface);
return 0;
}
The program create a png image, but it's filled in black whereas it should be white. I tried to draw paths and other forms but it seems that the image buffer isn't
modified. I'm working on Windows with DevC++ and use the cairo library provided with the GTK+ package for windows as indicated on the Cairo web site.
So, do you know why this code doesn't work ?
Thanks
PS: sorry for my English, I'm french :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20060710/47f30260/attachment.html
More information about the cairo
mailing list