[cairo] Newbie - simple program doesn't work
Behdad Esfahbod
behdad at behdad.org
Mon Jul 10 07:44:07 PDT 2006
On Mon, 2006-07-10 at 05:57 -0400, Fabien Costantini wrote:
>
> This is probably because cairo_fill() doesn't know what to fill in
> your code.
> you should add before your cairo_fill() call, something like :
> cairo_rectangle(cr,0,0,WIDTH,HEIGHT);
> so that cairo_fill() knows that the closed path on which to apply the
> fill is your whole surface.
Or just use cairo_paint() instead.
> Fabien
>
> ----- Message d'origine ----
> De : Baptiste Gaillard <b_gaillard at hotmail.com>
> À : cairo at cairographics.org
> Envoyé le : Lundi, 10 Juillet 2006, 11h34mn 47s
> Objet : [cairo] Newbie - simple program doesn't work
>
> 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 :-)
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
>
>
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
--
behdad
http://behdad.org/
"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
-- Dan Bern, "New American Language"
More information about the cairo
mailing list