void _icon_editor_gui_update() { char *tmp; Evas_Object *im_obj; void *im_data = NULL; int im_w = 0, im_h = 0; tmp = icon_editor_exec_get(); ewl_entry_text_set(EWL_ENTRY(editor->exec.entry), tmp); free(tmp); /* FIXME: set the name */ im_obj = EWL_IMAGE(editor->icon_image)->image; icon_editor_image_data_get(&im_data, &im_w, &im_h); if (!im_data) return; evas_object_image_size_set(im_obj, im_w, im_h); evas_object_image_data_copy_set(im_obj, im_data); evas_object_image_alpha_set(im_obj, 1); evas_object_image_data_update_add(im_obj, 0, 0, im_w, im_h); evas_object_image_fill_set(im_obj, 0, 0, im_w, im_h); printf("wxh: %d x %d\n", im_w, im_h); ewl_object_size_request(EWL_OBJECT(editor->icon_image), im_w, im_h); ewl_object_maximum_size_set(EWL_OBJECT(editor->icon_image), im_w, im_h); ewl_object_minimum_size_set(EWL_OBJECT(editor->icon_image), im_w, im_h); }
PassRefPtr<Evas_Object> evasObjectFromCairoImageSurface(Evas* canvas, cairo_surface_t* surface) { EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(surface, 0); cairo_status_t status = cairo_surface_status(surface); if (status != CAIRO_STATUS_SUCCESS) { EINA_LOG_ERR("cairo surface is invalid: %s", cairo_status_to_string(status)); return 0; } cairo_surface_type_t type = cairo_surface_get_type(surface); if (type != CAIRO_SURFACE_TYPE_IMAGE) { EINA_LOG_ERR("unknown surface type %d, required %d (CAIRO_SURFACE_TYPE_IMAGE).", type, CAIRO_SURFACE_TYPE_IMAGE); return 0; } cairo_format_t format = cairo_image_surface_get_format(surface); if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24) { EINA_LOG_ERR("unknown surface format %d, expected %d or %d.", format, CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_RGB24); return 0; } int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); int stride = cairo_image_surface_get_stride(surface); if (width <= 0 || height <= 0 || stride <= 0) { EINA_LOG_ERR("invalid image size %dx%d, stride=%d", width, height, stride); return 0; } void* data = cairo_image_surface_get_data(surface); if (!data) { EINA_LOG_ERR("could not get source data."); return 0; } RefPtr<Evas_Object> image = adoptRef(evas_object_image_filled_add(canvas)); if (!image) { EINA_LOG_ERR("could not add image to canvas."); return 0; } evas_object_image_colorspace_set(image.get(), EVAS_COLORSPACE_ARGB8888); evas_object_image_size_set(image.get(), width, height); evas_object_image_alpha_set(image.get(), format == CAIRO_FORMAT_ARGB32); if (evas_object_image_stride_get(image.get()) != stride) { EINA_LOG_ERR("evas' stride %d diverges from cairo's %d.", evas_object_image_stride_get(image.get()), stride); return 0; } evas_object_image_data_copy_set(image.get(), data); return image.release(); }
EAPI void e_icon_data_set(Evas_Object *obj, void *data, int w, int h) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERRNR(); if (!(sd = evas_object_smart_data_get(obj))) return; if (sd->edje) return; evas_object_image_size_set(sd->obj, w, h); evas_object_image_data_copy_set(sd->obj, data); }
EAPI void e_icon_data_set(Evas_Object *obj, void *data, int w, int h) { E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return; if (!strcmp(evas_object_type_get(sd->obj), "edje")) return; evas_object_image_size_set(sd->obj, w, h); evas_object_image_data_copy_set(sd->obj, data); }