From 840b2e8574217258193fb9d89310b251ed0ece39 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 8 Oct 2010 23:03:22 +0000 Subject: [PATCH] faster and better: png or jpeg, crop. if source file is a jpeg, then speed up and generate thumbnails in format "JPEG" that are smaller and faster to load. also define the aspect to be cropped rather than keep aspect as we're showing the images in a fixed square. The aspect one would be good if we did not use a grid, rather a flow layout. SVN revision: 53218 --- src/bin/ephoto.c | 2 +- src/bin/ephoto_main.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/bin/ephoto.c b/src/bin/ephoto.c index b7bf729..6397d27 100644 --- a/src/bin/ephoto.c +++ b/src/bin/ephoto.c @@ -26,7 +26,7 @@ main(int argc, char **argv) goto end_log_domain; } ethumb_client_crop_align_set(client, 0.5, 0.5); - ethumb_client_aspect_set(client, ETHUMB_THUMB_KEEP_ASPECT); + ethumb_client_aspect_set(client, ETHUMB_THUMB_CROP); ethumb_client_orientation_set(client, ETHUMB_THUMB_ORIENT_ORIGINAL); __log_domain = eina_log_domain_register("ephoto", EINA_COLOR_BLUE); if (!__log_domain) diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index ce7163f..d029fab 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -183,7 +183,12 @@ _thumb_gen_size_changed_timer_cb(void *data) ethumb_client_size_set(client, gen_size, gen_size); EINA_LIST_FOREACH(_thumbs, l, o) - elm_thumb_reload(o); + { + Ethumb_Thumb_Format format; + format = (long)evas_object_data_get(o, "ephoto_format"); + ethumb_client_format_set(client, format); + elm_thumb_reload(o); + } end: _thumb_gen_size_changed_timer = NULL; @@ -226,8 +231,27 @@ _thumb_del(void *data, Evas *e, Evas_Object *o, void *event_info) Evas_Object * ephoto_thumb_add(Evas_Object *parent, const char *path) { - Evas_Object *o = elm_thumb_add(parent); + Evas_Object *o; + const char *ext; + Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO; + + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL); + + o = elm_thumb_add(parent); if (!o) return NULL; + + ext = strrchr(path, '.'); + if (ext) + { + ext++; + if ((strcasecmp(ext, "jpg") == 0) || + (strcasecmp(ext, "jpeg") == 0)) + format = ETHUMB_THUMB_JPEG; /* faster! */ + } + + ethumb_client_format_set(elm_thumb_ethumb_client_get(), format); + evas_object_data_set(o, "ephoto_format", (void*)(long)format); elm_thumb_file_set(o, path, NULL); _thumbs = eina_list_append(_thumbs, o); evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, NULL);