/* setup */ static void _setup(void) { int i; Evas_Object *o; for (i = 0; i < NUM; i++) { o = evas_object_image_filled_add(evas); o_images[i] = o; evas_object_image_border_set(o, 2, 2, 2, 2); evas_object_image_file_set(o, build_path("pan.png"), NULL); evas_object_resize(o, win_w, ICON_SIZE); evas_object_show(o); o = evas_object_image_filled_add(evas); o_icons[i] = o; evas_object_image_border_set(o, 2, 2, 2, 2); evas_object_image_file_set(o, build_path(icons[i % 13]), NULL); evas_object_resize(o, ICON_SIZE - 8, ICON_SIZE - 8); evas_object_show(o); o = evas_object_text_add(evas); o_texts[i] = o; evas_object_text_font_set(o, "Vera-Bold", 10); evas_object_text_text_set(o, labels[i % 26]); evas_object_color_set(o, 0, 0, 0, 255); evas_object_show(o); } done = 0; }
static Game_Bg_Obj * _bg_obj_add(Game_Bg *bg, const char *name, int x, int y, int w, int h, int delta) { Game_Bg_Obj *bg_obj; char buf[1024]; Evas *evas; bg_obj = calloc(1, sizeof(Game_Bg_Obj)); if (!bg_obj) { ERR("Failed to create bg obj"); return NULL; } bg_obj->delta = delta; bg_obj->x = x; evas = evas_object_evas_get(bg->event); bg_obj->obj = evas_object_image_filled_add(evas); snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/%s.png", name); evas_object_image_file_set(bg_obj->obj, buf, NULL); evas_object_move(bg_obj->obj, x, FLOOR_Y + y); evas_object_resize(bg_obj->obj, w, h); evas_object_layer_set(bg_obj->obj, LAYER_BG); evas_object_show(bg_obj->obj); bg->objs = eina_list_append(bg->objs, bg_obj); return bg_obj; }
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_MAIN int elm_main(int argc, char **argv) { setpriority(PRIO_PROCESS, 0, +15); int x, y, w, h; if (argc > 1) { file=argv[1]; } if (argc > 2) { command=argv[2]; } if (argc > 3) { x=atof(argv[3]); } if (argc > 4) { y=atof(argv[4]); } if (argc > 5) { w=atof(argv[5]); } if (argc > 6) { h=atof(argv[6]); } else { printf("how to use: ./button_png filename command x y w h \n"); elm_exit(); exit(0); } win = elm_win_add(NULL, NULL, ELM_WIN_NOTIFICATION); elm_win_prop_focus_skip_set(win, EINA_TRUE); Evas *evas = evas_object_evas_get(win); evas_object_move(win, x, y); evas_object_resize(win,w,h); evas_object_show(win); // Create an image object Evas_Object *img = evas_object_image_filled_add(evas); evas_object_image_file_set(img, file, NULL); evas_object_move(img, 0, 0); evas_object_resize(img,w,h); evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_DOWN, _on_keydown, NULL); evas_object_show(img); ecore_main_loop_iterate(); elm_run(); return 0; }
//--------------------------------------------------------------------- //! @brief Constructor //--------------------------------------------------------------------- Image::Image( Evas* _win , bool _use_rh ) : image__() , image_pressed__() , visibility__( Visibility::INVISIBLE ) , use_rh__( _use_rh ) , path__() , path_pressed__() , rh__( Factory< IResourceHandler >::get( "EFL" ) ) , signal__( new Events::Signal() ) { image__ = evas_object_image_filled_add( _win ); image_pressed__ = evas_object_image_filled_add( _win ); CCallbackHandler::evasEventCallback( image__ , CALLBACK_MOUSE_DOWN , [=](){ mouseDown(); Factory< Timer >::get( "Timer" )->touchEvent(); } ); CCallbackHandler::evasEventCallback( image__ , CALLBACK_MOUSE_UP , [=](){ mouseUp(); } ); }
static PassRefPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize) { OwnArrayPtr<unsigned char> imageBuffer = adoptArrayPtr(new unsigned char[imageSize]); if (!imageBuffer) abortWithErrorMessage("cannot allocate image"); const size_t bytesRead = fread(imageBuffer.get(), 1, imageSize, stdin); if (!bytesRead) return PassRefPtr<Evas_Object>(); Evas_Object* image = evas_object_image_filled_add(evas); evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888); evas_object_image_memfile_set(image, imageBuffer.get(), bytesRead, 0, 0); resizeEcoreEvasIfNeeded(image); return adoptRef(image); }
static void cairo_evasgl_drawing(appdata_s *ad) { /* Window */ elm_config_accel_preference_set("opengl"); ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); elm_win_autodel_set(ad->win, EINA_TRUE); if (elm_win_wm_rotation_supported_get(ad->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); } evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad); evas_object_show(ad->win); /* Image */ ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win)); evas_object_show(ad->img); evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height); /* Init EVASGL */ Evas_Native_Surface ns; ad->evas_gl = evas_gl_new(evas_object_evas_get(ad->img)); ad->evas_gl_config = evas_gl_config_new(); ad->evas_gl_config->color_format = EVAS_GL_RGBA_8888; ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height); ad->evas_gl_context = evas_gl_context_create(ad->evas_gl, NULL); evas_gl_native_surface_get(ad->evas_gl, ad->evas_gl_surface, &ns); evas_object_image_native_surface_set(ad->img, &ns); evas_object_image_pixels_get_callback_set(ad->img, cairo_drawing_rt, ad); /* cairo & cairo device create with evasgl */ setenv("CAIRO_GL_COMPOSITOR", "msaa", 1); ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create (ad->evas_gl, ad->evas_gl_context); cairo_gl_device_set_thread_aware(ad->cairo_device, 0); ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, ad->evas_gl_config, ad->width, ad->height); ad->cairo = cairo_create (ad->surface); }
static Evas_Object* differenceImageFromDifferenceBuffer(Evas* evas, unsigned char* buffer, int width, int height) { Evas_Object* image = evas_object_image_filled_add(evas); if (!image) abortWithErrorMessage("could not create difference image"); evas_object_image_size_set(image, width, height); evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888); unsigned char* diffPixels = static_cast<unsigned char*>(evas_object_image_data_get(image, EINA_TRUE)); const int rowStride = evas_object_image_stride_get(image); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { unsigned char* diffPixel = pixelFromImageData(diffPixels, rowStride, x, y); diffPixel[Red] = diffPixel[Green] = diffPixel[Blue] = *buffer++; diffPixel[Alpha] = 0xff; } } evas_object_image_data_set(image, diffPixels); return image; }
EINTERN Eina_Bool e_mod_comp_pixmap_rotation_handler_message(Ecore_X_Event_Client_Message *ev) { Ecore_X_Atom type; Ecore_X_Window win; E_Comp_Win *cw = NULL; Ecore_X_Damage dmg; Eina_Bool r; cw = e_mod_comp_border_client_find(ev->win); if (!cw) { cw = e_mod_comp_win_find(ev->win); E_CHECK_RETURN(cw, 0); } type = ev->message_type; win = ev->win; if (type == ATOM_CM_PIXMAP_ROTATION_BEGIN) { E_CHECK_RETURN((!cw->pixrot), 0); cw->pixrot = e_mod_comp_pixmap_rotation_new(); E_CHECK_RETURN(cw->pixrot, 0); e_mod_comp_pixmap_rotation_state_set(cw->pixrot, 1); edje_object_part_unswallow(cw->shobj, cw->obj); _win_unredirect(cw); e_mod_comp_pixmap_rotation_done_send (win, ATOM_CM_PIXMAP_ROTATION_BEGIN_DONE); } else if (type == ATOM_CM_PIXMAP_ROTATION_END) { E_CHECK_RETURN(cw->pixrot, 0); e_mod_comp_effect_animating_set(cw->c, cw, EINA_FALSE); e_mod_comp_pixmap_rotation_handler_release(cw); } else if (type == ATOM_CM_PIXMAP_ROTATION_REQUEST) { E_CHECK_RETURN(cw->pixrot, 0); r = e_mod_comp_pixmap_rotation_state_get(cw->pixrot); E_CHECK_RETURN(r, 0); dmg = e_mod_comp_pixmap_rotation_damage_get(cw->pixrot); if (dmg) e_mod_comp_win_del_damage(cw, dmg); if (cw->obj) edje_object_part_unswallow(cw->shobj, cw->obj); else { E_CHECK_RETURN(cw->c, 0); cw->obj = evas_object_image_filled_add(cw->c->evas); evas_object_image_colorspace_set(cw->obj, EVAS_COLORSPACE_ARGB8888); if (cw->argb) evas_object_image_alpha_set(cw->obj, 1); else evas_object_image_alpha_set(cw->obj, 0); evas_object_show(cw->obj); evas_object_pass_events_set(cw->obj, 1); } r = e_mod_comp_pixmap_rotation_request (cw->pixrot, ev, cw->c->evas, cw->shobj, cw->obj, cw->vis, cw->w, cw->h); E_CHECK_RETURN(r, 0); e_mod_comp_update_resize(cw->up, cw->w, cw->h); e_mod_comp_update_add(cw->up, 0, 0, cw->w, cw->h); cw->native = 1; dmg = e_mod_comp_pixmap_rotation_damage_get(cw->pixrot); E_CHECK_RETURN(dmg, 0); e_mod_comp_win_add_damage(cw, dmg); e_mod_comp_pixmap_rotation_done_send (win, ATOM_CM_PIXMAP_ROTATION_REQUEST_DONE); } else return EINA_FALSE; return EINA_TRUE; }
EINTERN Eina_Bool e_mod_comp_pixmap_rotation_handler_configure(E_Comp_Win *cw, int w, int h) { Ecore_X_Window win; E_CHECK_RETURN(cw, 0); E_CHECK_RETURN(cw->pixrot, 0); E_CHECK_RETURN(((w == cw->w) && (h == cw->h)), 0); win = e_mod_comp_util_client_xid_get(cw); /* backup below obj */ Eina_Bool bottom = EINA_FALSE; Evas_Object *below_obj = evas_object_below_get(cw->shobj); if (!below_obj) { if (evas_object_bottom_get(cw->c->evas) == cw->shobj) { L(LT_EVENT_X, "[COMP] %31s w:0x%08x bd:%s shobj is bottom.\n", "PIX_ROT", e_mod_comp_util_client_xid_get(cw), cw->bd ? "O" : "X"); bottom = EINA_TRUE; } } if (cw->obj) { evas_object_hide(cw->obj); evas_object_del(cw->obj); cw->obj = NULL; } if (cw->shobj) { evas_object_hide(cw->obj); evas_object_del(cw->shobj); cw->shobj = NULL; } cw->shobj = edje_object_add(cw->c->evas); cw->obj = evas_object_image_filled_add(cw->c->evas); evas_object_image_colorspace_set(cw->obj, EVAS_COLORSPACE_ARGB8888); if (cw->argb) evas_object_image_alpha_set(cw->obj, 1); else evas_object_image_alpha_set(cw->obj, 0); e_mod_comp_win_type_setup(cw); e_mod_comp_win_shadow_setup(cw); e_mod_comp_win_cb_setup(cw); evas_object_show(cw->obj); evas_object_pass_events_set(cw->obj, 1); evas_object_pass_events_set(cw->shobj, 1); /* restore stack */ if (bottom) below_obj = evas_object_below_get(cw->shobj); evas_object_stack_above(cw->shobj, below_obj); L(LT_EVENT_X, "[COMP] %31s w:0x%08x bd:%s shobj restore stack.\n", "PIX_ROT", e_mod_comp_util_client_xid_get(cw), cw->bd ? "O" : "X"); e_mod_comp_pixmap_rotation_done_send (win, ATOM_CM_PIXMAP_ROTATION_RESIZE_PIXMAP); return EINA_TRUE; }
static int set1(Evas *e){ Evas_Object *img, *proxy, *lbl; int w,h; /* create an image,, but don't show */ label_add(e,10,0,"Hidden Source",false); img = evas_object_image_add(e); evas_object_image_file_set(img, images[0], NULL); /* don't do anything that may cause it to load */ w = 96; h = 98; evas_object_resize(img, w, h); evas_object_image_fill_set(img, 0, 0, w, h); evas_object_move(img, 10,10); label_add(e,w + 90,0,"Proxy",false); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_image_fill_set(proxy, 0, 0, w, h); evas_object_move(proxy, w + 90, 10); evas_object_show(proxy); /* * Test a hidden label */ label_add(e, 10, 120, "Hidden Text", false); lbl = label_add(e, 10, 120, "Can't See ME!", false); evas_object_hide(lbl); label_add(e, 200, 120, "Proxy Text", false); w = 200; h = 200; proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, lbl); evas_object_resize(proxy, w, h); evas_object_image_fill_set(proxy, 0, 0, w, h); evas_object_move(proxy, 200, 120); evas_object_show(proxy); /* * Invisible text block */ img = textblock_add(e, 600, 200); evas_object_hide(img); evas_object_geometry_get(img, NULL, NULL, &w, &h); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 10, 320); evas_object_show(proxy); flip_map(proxy); /* * Test an offscreen 'widget' */ img = sp_add(e); evas_object_move(img, -300,200); evas_object_resize(img, 100, 20); ecore_timer_add(0.05, smart_animate, img); w = 100; h = 20; proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 300, 300); evas_object_show(proxy); flip_map(proxy); return 0; }
int set0(Evas *e){ Evas_Object *img, *proxy; bool rv; int w,h; struct imageupdate *iu; //int minw,minh,maxw,maxh; label_add(e,10,0,"The Source",false); img = evas_object_image_filled_add(e); evas_object_image_file_set(img, images[0], NULL); evas_object_image_size_get(img, &w, &h); w = w/2; h = h/2; evas_object_resize(img, w, h); evas_object_move(img, 10,10); evas_object_show(img); iu = calloc(1,sizeof(struct imageupdate)); iu->cur = 0; iu->max = N_IMAGES; iu->obj = img; iu->imagelist = images; ecore_timer_add(1.4, image_next, iu); label_add(e,20+w,0,"Normal Proxy",false); proxy = evas_object_image_filled_add(e); if (!proxy){ printf("Unable to create proxy object\n"); return 1; } rv = evas_object_image_source_set(proxy, img); if (rv != true){ printf("Error setting proxy source\n"); return 1; } evas_object_resize(proxy, w, h); evas_object_move(proxy, 20 + w, 10); /* If this is uncommented: Moves proxy evyer second (swap x/y) */ //iu->proxy = proxy; evas_object_show(proxy); label_add(e,10,h + 20, "Reflected Proxy",false); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 10, 30+h); evas_object_show(proxy); flip_map(proxy); label_add(e,20+w,h+20,"Squish Proxy",false); proxy = evas_object_image_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h / 2); evas_object_image_fill_set(proxy, 0,0, w, h/2); evas_object_move(proxy, 20+w, 30+h); evas_object_show(proxy); /* Proxy a label */ img = label_add(e, 300, 10, "Label Source ",true); evas_object_geometry_get(img, NULL, NULL, &w, &h); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 300, 10 + h + 3); evas_object_show(proxy); flip_map(proxy); label_add(e, 440, 10, "Squish Label",false); proxy = evas_object_image_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h / 2); evas_object_image_fill_set(proxy, 0,0,w,h/2); evas_object_move(proxy, 440, 10 + h + 3); evas_object_show(proxy); label_add(e, 440, 60, "Stretch Label",false); proxy = evas_object_image_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_image_fill_set(proxy, 0,0,w, h); evas_object_move(proxy, 440, 60 + h + 3); evas_object_show(proxy); label_add(e, 240, 60, "Highlight", false); proxy = evas_object_image_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, 50,50); evas_object_image_fill_set(proxy, -w/2,-h/2,w*3,h*3); evas_object_move(proxy, 250, 60 + h + 3); evas_object_show(proxy); img = label_add(e, 400, 120, "Zoomy Text!", false); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 350, 150); zoom_map(proxy); evas_object_show(proxy); /* Proxy a text block */ img = textblock_add(e, 10, 200); evas_object_geometry_get(img, NULL, NULL, &w, &h); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 10, 320); evas_object_show(proxy); flip_map(proxy); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w/2, h/2); evas_object_move(proxy, 10 + w, 320); evas_object_show(proxy); /* The 'smart' object */ img = sp_add(e); evas_object_move(img, 300,200); evas_object_resize(img, 100, 20); ecore_timer_add(0.05, smart_animate, img); w = 100; h = 20; proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w, h); evas_object_move(proxy, 300, 240); evas_object_show(proxy); flip_map(proxy); proxy = evas_object_image_filled_add(e); evas_object_image_source_set(proxy, img); evas_object_resize(proxy, w * 2, h / 3); evas_object_image_fill_set(proxy, 0, 0, w * 2, h /3 ); evas_object_move(proxy, 420, 240); evas_object_show(proxy); img = evas_object_image_filled_add(e); proxy = evas_object_image_filled_add(e); evas_object_move(img, 500, 300); evas_object_move(proxy, 600, 300); evas_object_resize(img, 100, 100); evas_object_resize(proxy, 100, 100); evas_object_show(img); evas_object_show(proxy); evas_object_image_source_set(img, proxy); evas_object_image_source_set(proxy, img); #if 0 label_add(e, 300,90, "Edje File", false); img = edje_object_add(e); if (!_edje_load_or_show_error(img, "basic.edj", "proxytest")){ evas_object_del(img); } evas_object_resize(img,220,200); evas_object_move(img,300,100); evas_object_show(img); edje_object_size_max_get(img, &maxw, &maxh); edje_object_size_min_get(img, &minw, &minh); if ((minw <= 0) && (minh <= 0)) edje_object_size_min_calc(img, &minw, &minh); evas_object_size_hint_max_set(img, maxw, maxh); evas_object_size_hint_min_set(img, minw, minh); evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL); #endif /* The edje file */ return 0; }