[Vala] How to draw on a pixbuf



Hello everyone,

I want to prepare a picture and paste in a drawingarea, so I thought I
should draw on a pixbuf, then copy it to my drawingarea....

I've create a drawing area (500x500) and I've tried this code in "on_draw" :
    public bool on_draw(Widget da, Context context) {
(...)
        var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 100, 100);
        Surface s = Gdk.cairo_surface_create_from_pixbuf (pixbuf, 1, null);
        Context c = new Context (s);
        c.move_to(0, 0);
        c.line_to(50, 50);
        c.stroke();

        Gdk.cairo_set_source_pixbuf (context, pixbuf, 0, 0);

        context.paint ();
(...)

But the result is a partially black rectangle with some with points....

Have you some advices ? :)

Thanks.

Regards

Raum


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]