I can not show a canvas

I can not show a canvas

BY 27 Feb 2017 Native Application Development

Hi to all,

I have two questions, first and more basic, I have this code, supose to show some shapes in the screen, but is not showing nothing:

Evas_Object *img;
    img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
    evas_object_show(img);
    cairo_surface_t *surface;
    cairo_t *cairo;
    evas_object_geometry_get(ad->win, NULL, NULL, &screen_size_w, &screen_size_h);
    surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, screen_size_w, screen_size_h);
    cairo = cairo_create (surface);
    cairo_set_source_rgba(cairo, 1, 1, 1, 1);
        cairo_paint(cairo);

        cairo_translate(cairo,100, 100);
        cairo_set_line_width(cairo,2);
        cairo_set_source_rgba(cairo, 0.0, 0.0, 1.0, 1.0);
        cairo_move_to (cairo, 200 , 200);
            cairo_line_to (cairo, 400, 300);
            cairo_rel_line_to (cairo, 200 , 100);
        cairo_surface_flush(surface);
        unsigned char * imageData = cairo_image_surface_get_data(cairo_get_target(cairo));
            evas_object_image_data_set(img, imageData);
            evas_object_image_data_update_add(img, 0, 0, screen_size_w, screen_size_h);

 

Second question, Is possible to use the canvas object to draw, not on the window, to draw on a, for example, label object?

Thanks to all!!

Written by