Ejemplo n.º 1
0
        //---------------------------------------------------------------------
        //! @brief Set the image to display.
        //! @param[in] _path The path to the image.
        //---------------------------------------------------------------------
        void Image::setImage( std::string const& _path )
        {
            path__ = IMG_LOCATION + "/" + _path;
            path_pressed__ = path__;
            path_pressed__.insert( path_pressed__.find_last_of( "." )
                               , "_pressed" );

            if( use_rh__ )
            {
                rh__->copyResource( image__
                                  , path__ );
                rh__->copyResource( image_pressed__
                                  , path_pressed__ );
            }
            else
            {
                evas_object_image_file_set( image__
                                          , path__.c_str()
                                          , nullptr );
                evas_object_image_file_set( image_pressed__
                                          , path_pressed__.c_str()
                                          , nullptr );

                ASSERT( EVAS_LOAD_ERROR_NONE == evas_object_image_load_error_get( image__ )
                      , "There was an error loading image: " + path__ );
                ASSERT( EVAS_LOAD_ERROR_NONE == evas_object_image_load_error_get( image_pressed__ )
                      , "There was an error loading image: " + path_pressed__ );
            }
        }
Ejemplo n.º 2
0
void EflResources::preloadCachedImageCb__( std::string const& _path )
{
    if( 0 < preloaded_images__.count( _path ) )
    {
        Evas_Object* object = preloaded_images__[_path];

        evas_object_image_load_size_set( object
                                       , max_width__
                                       , max_height__ );
        std::string cached_file( cache_dir + _path );
        evas_object_image_file_set( object
                                  , cached_file.c_str()
                                  , nullptr );
        if( EVAS_LOAD_ERROR_NONE != evas_object_image_load_error_get( object ) )
        {
            signals__[PRELOAD_FAIL]->emit();
            LOGGER( "Failed to load image file: " + _path );
        }
        else
        {
            CCallbackHandler::evasEventCallback( object
                                               , CALLBACK_IMAGE_PRELOADED
                                               , [=](){ signals__[PRELOAD_SUCCESS]->emit(); } );
            evas_object_image_preload( object
                                     , 0 );
        }
    }
}
Ejemplo n.º 3
0
EAPI Eina_Bool
e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
{
   E_Smart_Data *sd;
   const char *path;
   int len;

   if (!icon) return EINA_FALSE;
   if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
   if (icon[0] == '/') return e_icon_file_set(obj, icon);

   if (!(sd = evas_object_smart_data_get(obj)))
     return EINA_FALSE;

   if (sd->timer) ecore_timer_del(sd->timer);
   sd->timer = NULL;
   if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation);
   sd->guessing_animation = NULL;
   sd->frame = 0;
   sd->frame_count = 0;
   sd->edje = EINA_FALSE;

   eina_stringshare_replace(&sd->fdo, icon);
   if (!sd->fdo) return EINA_FALSE;

   path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
   if (!path) return EINA_FALSE;

   len = strlen(icon);
   if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
     return e_icon_file_edje_set(obj, path, "icon");

   /* smart code here */
   _e_icon_obj_prepare(obj, sd);
   sd->loading = 0;
   if (sd->size != 0)
     evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
   if (sd->preload) evas_object_hide(sd->obj);
   evas_object_image_file_set(sd->obj, path, NULL);
   if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
     return EINA_FALSE;
   if (sd->preload)
     {
        sd->loading = 1;
        evas_object_image_preload(sd->obj, 0);
     }
   else if (evas_object_visible_get(obj))
     evas_object_show(sd->obj);
   _e_icon_smart_reconfigure(sd);
   return EINA_TRUE;
}
Ejemplo n.º 4
0
EAPI Eina_Bool
e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
{
   E_Smart_Data *sd;

   if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
   if (!(sd = evas_object_smart_data_get(obj)))
     return EINA_FALSE;

   /* smart code here */
   sd->loading = 0;
   if (sd->fdo)
     {
        eina_stringshare_del(sd->fdo);
        sd->fdo = NULL;
     }

   if (sd->timer) ecore_timer_del(sd->timer);
   sd->timer = NULL;
   if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation);
   sd->guessing_animation = NULL;
   sd->frame = 0;
   sd->frame_count = 0;
   sd->edje = EINA_FALSE;

   _e_icon_obj_prepare(obj, sd);
   if (sd->size != 0)
     evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
   if (sd->preload) evas_object_hide(sd->obj);
   evas_object_image_file_set(sd->obj, file, key);
   if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
     return EINA_FALSE;
   if (!_handle_anim(sd))
     {
        if (sd->preload)
          {
             sd->loading = 1;
             evas_object_image_preload(sd->obj, 0);
          }
        else if (evas_object_visible_get(obj))
          evas_object_show(sd->obj);
     }
   _e_icon_smart_reconfigure(sd);
   return EINA_TRUE;
}
Ejemplo n.º 5
0
void CalaosCameraView::requestCompleted()
{
    if (single_frame)
    {
        evas_object_image_memfile_set(camImage, &buffer[0], buffer.size(), NULL, NULL);

        Evas_Load_Error err = evas_object_image_load_error_get(camImage);
        if (err != EVAS_LOAD_ERROR_NONE)
            cErrorDom("camera") << "could not load image. error string is \"%s\"" << evas_load_error_str(err);
    }

    if (format_error)
        return;

    EcoreTimer::singleShot(0, [=]()
    {
        if (!single_frame)
            cWarningDom("camera") << "Restarting request to camera...";
        play();
    });
}
Ejemplo n.º 6
0
static Evas_Object *
engage_element_icon_new(Evas * evas, const char *file, const char *group)
{
  int             iw, ih;
  Evas_Object    *result = NULL;

  /* edje */
  if (group) {
    if (file && file[0] == '/') {
      result = edje_object_add(evas);
      if (edje_object_file_set(result, file, group) > 0) {
        evas_object_move(result, -9999, -9999);
        evas_object_resize(result, 4, 4);
      }
    } else {
      evas_object_del(result);
      result = NULL;
    }
  }
  /* image */
  else {
    if (file && file[0] == '/') {
      result = evas_object_image_add(evas);
      evas_object_image_file_set(result, file, NULL);
      switch (evas_object_image_load_error_get(result)) {
      case EVAS_LOAD_ERROR_NONE:
        evas_object_move(result, -9999, -9999);
        evas_object_resize(result, 4, 4);
        break;
      default:
        evas_object_del(result);
        result = NULL;
      }
    } else {
      evas_object_del(result);
      result = NULL;
    }
  }
  return (result);
}
Ejemplo n.º 7
0
static void _walle_wall_populate(Walle *walle, const char *directory, const char *theme)
{
    Evas_Object *o;
    Evas_Coord ow, oh, w, h;
    Eina_List *files = NULL;
    char *file = NULL;
    char filename[4096];

    if (!ecore_file_is_dir(directory) && ecore_file_dir_is_empty(directory))
        return;
    files = ecore_file_ls(directory);
    if (!files)
        return;
    EINA_LIST_FREE(files, file)
    {
    	sprintf(filename, "%s/%s", directory, file);
    	o = evas_object_image_add(walle->evas);
    	evas_object_image_file_set(o, filename, NULL);
    	switch(evas_object_image_load_error_get(o))
    	{
    	case EVAS_LOAD_ERROR_NONE:
    	{
    	    evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _walle_picture_cb_resize, o);
    	    evas_object_image_size_get(o, &w, &h);
    	    oh = 200;
    	    ow = oh * (float)w/(float)h;
    	    evas_object_image_load_size_set(o, ow, oh);
    	    evas_object_image_fill_set(o, 0, 0, ow, oh);
    	    evas_object_resize(o, ow, oh);
    	    evas_object_size_hint_min_set(o, ow, oh);
    	    walle_wall_append(walle->o_wall, o);
    	    walle->pictures = eina_list_append(walle->pictures, o);
    	}
    	break;
    	default:
    	    evas_object_del(o);
    	    break;
    	}
    }
Ejemplo n.º 8
0
static int
_elixir_evas_object_image_load_error_get(const Evas_Object *obj)
{
   return (int) evas_object_image_load_error_get(obj);
}
Ejemplo n.º 9
0
int main(void)
{
  if(!ecore_evas_init())
    return EXIT_FAILURE;

  Ecore_Evas *e_e;
  Evas *e_evas;
  Evas_Object *e_ret, *img_1, *img_clip, *cute_1, *cute_2, *cute_mini_1, *cute_mini_2, *cute_mini_clip_1, *cute_mini_clip_2;

  e_e = ecore_evas_new(NULL,0,0,1600,1000,NULL);
  if (!e_e) return EXIT_FAILURE;

  ecore_evas_show(e_e);
  e_evas = ecore_evas_get(e_e);
  if (!e_evas) return EXIT_FAILURE;

  e_ret = evas_object_rectangle_add(e_evas);
  if (!e_ret) return EXIT_FAILURE;
  evas_object_color_set(e_ret,0,155,255,255);
  evas_object_move(e_ret,0,0);
  evas_object_resize(e_ret,1600,1000);
  evas_object_show(e_ret);

  cute_1 = evas_object_image_add(e_evas);
  evas_object_image_file_set(cute_1,"/home/luciana/Public/Enlightenment/cute_cat.jpeg",NULL);
  evas_object_move(cute_1,0,0);
  evas_object_resize(cute_1,640,400);
  evas_object_image_fill_set(cute_1,0,0,640,400);
  evas_object_show(cute_1);
 
  cute_2 = evas_object_image_add(e_evas);
  evas_object_image_file_set(cute_2,"/home/luciana/Public/Enlightenment/cute_cat.jpeg",NULL);
  evas_object_move(cute_2,960,600);
  evas_object_resize(cute_2,640,400);
  evas_object_image_fill_set(cute_2,0,0,640,400);
  evas_object_show(cute_2); 
  

  cute_mini_1 = evas_object_image_add(e_evas);
  evas_object_image_file_set(cute_mini_1,"/home/luciana/Public/Enlightenment/cute_cat.jpeg",NULL);
  evas_object_move(cute_mini_1,640,400);
  evas_object_resize(cute_mini_1,640,400);
  evas_object_image_fill_set(cute_mini_1,0,0,320,200);
  evas_object_resize(cute_mini_1,320,200);
  evas_object_show(cute_mini_1);

  cute_mini_2 = evas_object_image_add(e_evas);
  evas_object_image_file_set(cute_mini_2,"/home/luciana/Public/Enlightenment/cute_cat.jpeg",NULL);
  evas_object_move(cute_mini_2,640,400);
  evas_object_resize(cute_mini_2,640,400);
  evas_object_image_fill_set(cute_mini_2,0,0,320,200);
  evas_object_resize(cute_mini_2,320,200);
  evas_object_show(cute_mini_2);
    
  Evas_Load_Error err;
  if( (err = evas_object_image_load_error_get(img_1)) != EVAS_LOAD_ERROR_NONE)
    {
      fprintf(stderr, "error: %s\n", evas_load_error_str(err));
      exit(EXIT_FAILURE);
    }

  /* cute_mini_alpha = evas_object_rectangle_add(e_evas); */
  /* evas_object_color_set(cute_mini_alpha,255,255,255,155); */
  /* evas_object_move(cute_mini_alpha,6400,400); */
  /* evas_object_resize(cute_mini_alpha,320,200); */
  /* evas_object_clip_set(cute_mini,cute_mini_alpha); */
  /* evas_object_show(cute_mini_alpha); */
  
  cute_mini_clip_1 = evas_object_rectangle_add(e_evas);
  evas_object_color_set(cute_mini_clip_1,255,255,255,255);
  evas_object_move(cute_mini_clip_1,640,400);
  evas_object_resize(cute_mini_clip_1,160,100);
  evas_object_clip_set(cute_mini_1,cute_mini_clip_1);
  evas_object_show(cute_mini_clip_1);

  cute_mini_clip_2 = evas_object_rectangle_add(e_evas);
  evas_object_color_set(cute_mini_clip_2,255,255,255,255);
  evas_object_move(cute_mini_clip_2,800,500);
  evas_object_resize(cute_mini_clip_2,160,100);
  evas_object_clip_set(cute_mini_2,cute_mini_clip_2);
  evas_object_show(cute_mini_clip_2);

  ecore_main_loop_begin();

  ecore_evas_free(e_e);
  ecore_evas_shutdown();
  return 0;
}
Ejemplo n.º 10
0
/* Image: render() */
static Etk_Bool _image_render(Etk_Tree_Model *model, Etk_Tree_Row *row, Etk_Geometry geometry, void *cell_data, Evas_Object *cell_objects[ETK_TREE_MAX_OBJECTS_PER_MODEL], Evas *evas)
{
   Etk_Tree_Model_Image *image_model;
   Etk_Tree_Model_Image_Data *image_data;
   int image_width, image_height;
   Etk_Geometry image_geometry;
   Etk_Bool object_created = ETK_FALSE;
   float aspect;
   char *ext;

   if (!(image_model = (Etk_Tree_Model_Image *)model) || !(image_data = cell_data) || !evas)
      return ETK_FALSE;

   if (!image_data->filename || image_data->type == ETK_TREE_MODEL_NOT_FOUND)
      return ETK_FALSE;

   /* If we don't know yet what the image's type is, we "guess" it */
   if (image_data->type == ETK_TREE_MODEL_UNKNOWN_YET)
   {
      if (!image_data->key)
         image_data->type = ETK_TREE_MODEL_NORMAL;
      else if ((ext = strrchr(image_data->filename, '.')) && strcasecmp(ext + 1, "eet") == 0)
         image_data->type = ETK_TREE_MODEL_NORMAL;
      else
         image_data->type = ETK_TREE_MODEL_EDJE;
   }

   /* If the object is not already in the cache, we load it */
   if (!(cell_objects[0] = etk_cache_find(image_model->cache, image_data->filename, image_data->key)))
   {
      if (image_data->type == ETK_TREE_MODEL_NORMAL)
      {
         cell_objects[0] = evas_object_image_add(evas);
         evas_object_pass_events_set(cell_objects[0], 1);

         evas_object_image_file_set(cell_objects[0], image_data->filename, image_data->key);
         if (!evas_object_image_load_error_get(cell_objects[0]))
            object_created = ETK_TRUE;
         else
            image_data->type = ETK_TREE_MODEL_NOT_FOUND;
      }
      /* If it's not a normal image file, then it's an Edje file... */
      else
      {
         cell_objects[0] = edje_object_add(evas);
         evas_object_pass_events_set(cell_objects[0], 1);

         if (edje_object_file_set(cell_objects[0], image_data->filename, image_data->key))
            object_created = ETK_TRUE;
         else
            image_data->type = ETK_TREE_MODEL_NOT_FOUND;
      }
   }

   /* If loading the image has failed, we destroy the object and return */
   if (image_data->type == ETK_TREE_MODEL_NOT_FOUND)
   {
      if (cell_objects[0])
      {
         evas_object_del(cell_objects[0]);
         cell_objects[0] = NULL;
      }
      return ETK_FALSE;
   }

   /* The image is correctly loaded, we can now render it */
   if (image_data->type == ETK_TREE_MODEL_NORMAL)
      evas_object_image_size_get(cell_objects[0], &image_width, &image_height);
   else
      edje_object_size_min_get(cell_objects[0], &image_width, &image_height);

   if (image_width == 0 || image_height == 0)
   {
      image_width = geometry.h;
      image_height = geometry.h;
   }
   aspect = ((float)image_width / image_height);

   /* No limitation of width */
   if (image_model->width <= 0)
   {
      if (image_height <= geometry.h)
      {
         image_geometry.w = image_width;
         image_geometry.h = image_height;
      }
      else
      {
         image_geometry.w = geometry.h * aspect;
         image_geometry.h = geometry.h;
      }

      image_geometry.x = geometry.x;
      image_geometry.y = geometry.y + ((geometry.h - image_geometry.h) / 2);
   }
   /* The max width is limited */
   else
   {
      if ((image_width > image_model->width || image_height > geometry.h))
      {
         /* The image doesn't fit in, we need to resize it */

         if (geometry.h * aspect > image_model->width)
         {
            image_geometry.w = image_model->width;
            image_geometry.h = image_model->width / aspect;
         }
         else
         {
            image_geometry.w = geometry.h * aspect;
            image_geometry.h = geometry.h;
         }
      }
      else
      {
         image_geometry.w = image_width;
         image_geometry.h = image_height;
      }

      image_geometry.x = geometry.x + ((image_model->width - image_geometry.w) * image_model->halign);
      image_geometry.y = geometry.y + ((geometry.h - image_geometry.h) / 2);
   }

   if (image_data->type == ETK_TREE_MODEL_NORMAL)
      evas_object_image_fill_set(cell_objects[0], 0, 0, image_geometry.w, image_geometry.h);
   evas_object_move(cell_objects[0], image_geometry.x, image_geometry.y);
   evas_object_resize(cell_objects[0], image_geometry.w, image_geometry.h);
   evas_object_show(cell_objects[0]);

   return object_created;
}
Ejemplo n.º 11
0
EAPI Eina_Bool
e_icon_file_set(Evas_Object *obj, const char *file)
{
   E_Smart_Data *sd;
   int len;

   if (!file) return EINA_FALSE;
   if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
   if (!(sd = evas_object_smart_data_get(obj)))
     return EINA_FALSE;

   len = strlen(file);
   if ((len > 4) && (!strcasecmp(file + len - 4, ".edj")))
     return e_icon_file_edje_set(obj, file, "icon");

   /* smart code here */
   _e_icon_obj_prepare(obj, sd);
   /* FIXME: 64x64 - unhappy about this. use icon size */
   sd->loading = 0;
   if (sd->fdo)
     {
        eina_stringshare_del(sd->fdo);
        sd->fdo = NULL;
     }

   if (sd->timer) ecore_timer_del(sd->timer);
   sd->timer = NULL;
   if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation);
   sd->guessing_animation = NULL;
   sd->frame = 0;
   sd->frame_count = 0;
   sd->edje = EINA_FALSE;

   if (sd->size != 0)
     evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
   if (sd->preload) evas_object_hide(sd->obj);

#ifdef USE_ICON_CACHE
   if (_e_icon_cache_find(obj, file))
     {
        _e_icon_smart_reconfigure(sd);
        return EINA_TRUE;
     }
#endif

   evas_object_image_file_set(sd->obj, file, NULL);
   if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
     return EINA_FALSE;

   if (!_handle_anim(sd))
     {
        if (sd->preload)
          {
             sd->loading = 1;
             evas_object_image_preload(sd->obj, EINA_FALSE);
          }
        else if (evas_object_visible_get(obj))
          {
             evas_object_show(sd->obj);
#ifdef USE_ICON_CACHE
             _e_icon_cache_icon_loaded(sd->ci);
#endif
          }
     }
#ifdef USE_ICON_CACHE
   else
     {
        evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL,
                                            _e_icon_obj_del, obj);
        _cache->load_queue = eina_list_remove(_cache->load_queue, sd->ci);
        eina_stringshare_del(sd->ci->id);
        E_FREE(sd->ci);
        sd->ci = NULL;
     }
#endif

   _e_icon_smart_reconfigure(sd);
   return EINA_TRUE;
}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
    Ecore_Evas *ee;
    Evas_Object *bridge, *img;
    const char *opt, *input, *output, *params;
    int r = 0, w = -1, h = -1, err;
    double scale = -1.0;

    if (argc < 4) {
        fprintf(stderr,
                "Usage:\n"
                "\t%s <percentage%%|WxH|w=W|h=H> <input> <output>"
                " [save-params]\n"
                "where save-params is evas supported parameters, like:\n"
                "\tquality=85\n"
                "\tcompress=9\n",
                argv[0]);
        return 1;
    }

    opt = argv[1];
    input = argv[2];
    output = argv[3];
    params = argv[4];

    if (strncasecmp(opt, "w=", 2) == 0) {
        char *end = NULL;
        w = strtol(opt + 2, &end, 10);
        if (!end || *end != '\0') {
            fprintf(stderr, "ERROR: invalid decimal integer '%s'\n",
                    opt + 2);
            return 1;
        } else if (w < 1) {
            fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w);
            return 1;
        }
    } else if (strncasecmp(opt, "h=", 2) == 0) {
        char *end = NULL;
        h = strtol(opt + 2, &end, 10);
        if (!end || *end != '\0') {
            fprintf(stderr, "ERROR: invalid decimal integer '%s'\n",
                    opt + 2);
            return 1;
        } else if (h < 1) {
            fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h);
            return 1;
        }
    } else if (strchr(opt, '%')) {
        char *end = NULL;
        scale = strtod(opt, &end);
        if (!end || *end != '%') {
            fprintf(stderr, "ERROR: invalid percentual '%s'\n", opt);
            return 1;
        } else if (scale <= 0.0) {
            fprintf(stderr, "ERROR: invalid percentual %g, must be > 0.0\n",
                    scale);
            return 1;
        }
        scale /= 100.0;
    } else if (strchr(opt, 'x')) {
        if (sscanf(opt, "%dx%d", &w, &h) != 2) {
            fprintf(stderr, "ERROR: invalid size format '%s'\n", opt);
            return 1;
        } else if (w < 1) {
            fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w);
            return 1;
        } else {
            fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h);
            return 1;
        }
    } else {
        fprintf(stderr,
                "ERROR: first parameter must be in format:\n"
                "\tpercentage%%    - example: 10%%\n"
                "\tWxH            - example: 1024x768\n"
                "\tw=W            - example: w=1024\n"
                "\th=H            - example: h=768\n"
                "But '%s' was used!\n",
                opt);
        return 1;
    }

    ecore_evas_init();
    evas_init();

    ee = ecore_evas_buffer_new(1, 1);
    bridge = ecore_evas_object_image_new(ee);
    img = evas_object_image_add(ecore_evas_object_evas_get(bridge));
    evas_object_image_smooth_scale_set(img, EINA_TRUE);

    if (w > 0 && h > 0)
        evas_object_image_load_size_set(img, w, h);

    evas_object_image_file_set(img, input, NULL);
    err = evas_object_image_load_error_get(img);
    if (err != EVAS_LOAD_ERROR_NONE) {
        const char *msg = evas_load_error_str(err);
        fprintf(stderr, "ERROR: could not load '%s': %s\n", input, msg);
        r = 1;
        goto end;
    }

    if (w < 1 || h < 1) {
        int iw, ih;
        evas_object_image_size_get(img, &iw, &ih);

        if (iw < 0 || ih < 0) {
            fprintf(stderr, "ERROR: invalid source image size %dx%d (%s)\n",
                    iw, ih, input);
            goto end;
        }

        if (scale > 0) {
            w = ceil(iw * scale);
            h = ceil(ih * scale);
        } else if (w < 1)
            w = ceil(iw * (double)h / (double)ih);
        else if (h < 1)
            h = ceil(ih * (double)w / (double)iw);

        if (iw != w && ih != h)
            evas_object_image_load_size_set(img, w, h);
    }

    printf("output: %s, size: %dx%d, alpha: %s, params: %s\n",
           output, w, h,
           evas_object_image_alpha_get(img) ? "yes" : "no",
           params ? params : "<none>");

    evas_object_image_fill_set(img, 0, 0, w, h);
    evas_object_resize(img, w, h);
    evas_object_show(img);

    evas_object_image_alpha_set(bridge, evas_object_image_alpha_get(img));
    evas_object_image_size_set(bridge, w, h);
    ecore_evas_manual_render(ecore_evas_object_ecore_evas_get(bridge));

    evas_object_image_save(bridge, output, NULL, params);

  end:
    evas_object_del(img);
    evas_object_del(bridge);
    ecore_evas_free(ee);

    evas_shutdown();
    ecore_evas_shutdown();

    return r;
}
Ejemplo n.º 13
0
//Create a new menu item of type "item_type"
//This item will be automatically freed by calling eclair_menu_free on the parent menu
//Return NULL if failed
Eclair_Menu_Item *eclair_menu_item_new(const char *label, Eclair_Menu *parent, Eclair_Menu_Item_Type item_type, const char *icon_path)
{
   Eclair_Menu_Item *item;
   int result;

   if (!parent)
      return NULL;

   item = calloc(1, sizeof(Eclair_Menu_Item));
   item->type = item_type;

   //We load the edje object of the item
   item->edje_object = edje_object_add(parent->evas);
   if (item->type == ECLAIR_MENU_ITEM_SEPARATOR_ITEM)
      result = edje_object_file_set(item->edje_object, ECLAIR_WIDGETS_THEME, "eclair_menu_separator");
   else
      result = edje_object_file_set(item->edje_object, ECLAIR_WIDGETS_THEME, "eclair_menu_item");
   if (!result)
   {
      evas_object_del(item->edje_object);
      item->edje_object = NULL;
      return 0;
   }
   evas_object_event_callback_add(item->edje_object, EVAS_CALLBACK_MOUSE_IN, _eclair_menu_item_in_cb, item);
   evas_object_event_callback_add(item->edje_object, EVAS_CALLBACK_MOUSE_OUT, _eclair_menu_item_out_cb, item);
   evas_object_event_callback_add(item->edje_object, EVAS_CALLBACK_MOUSE_UP, _eclair_menu_item_up_cb, item);
   evas_object_show(item->edje_object);

   //We load the icon
   if (item->type == ECLAIR_MENU_ITEM_ICON_ITEM)
   {
      char *icon_size_str;
      int icon_size;

      item->icon_object = evas_object_image_add(parent->evas);
      evas_object_image_file_set(item->icon_object, icon_path, NULL);
      if (evas_object_image_load_error_get(item->icon_object))
      {
         evas_object_del(item->icon_object);
         item->icon_object = NULL;
         item->type = ECLAIR_MENU_ITEM_NORMAL_ITEM;
      }
      else
      {
         if ((icon_size_str = edje_file_data_get(ECLAIR_WIDGETS_THEME, "icon_size")))
         {
            icon_size = atoi(icon_size_str);
            evas_object_image_fill_set(item->icon_object, 0, 0, icon_size, icon_size);
            free(icon_size_str);
         }
         else
            evas_object_image_fill_set(item->icon_object, 0, 0, 16, 16);
         edje_object_part_swallow(item->edje_object, "icon", item->icon_object);
         evas_object_pass_events_set(item->icon_object, 1);
         evas_object_show(item->edje_object);
      }
   }

   eclair_menu_append_item(parent, item);

   if (item->type != ECLAIR_MENU_ITEM_SEPARATOR_ITEM)
      eclair_menu_item_label_set(item, label);

   return item;
}