From 3df5cac02fe2c26540923e3b2b36ed6c415cf4b1 Mon Sep 17 00:00:00 2001 From: Hyoyoung Chang Date: Tue, 1 Feb 2011 15:56:48 +0900 Subject: [PATCH] [cnp_helper] adjust pasting image size --- src/lib/elm_cnp_helper.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/lib/elm_cnp_helper.c b/src/lib/elm_cnp_helper.c index 14fdea5..764ef60 100644 --- a/src/lib/elm_cnp_helper.c +++ b/src/lib/elm_cnp_helper.c @@ -1118,16 +1118,55 @@ static Eina_Bool pasteimage_append(Paste_Image *pi, Evas_Object *entry) { char *entrytag; - char *tagstring = ""; + char *tagstring = ""; if (!pi) return EINA_FALSE; if (!entry) return EINA_FALSE; + char *imgres = alloca(sizeof(char)*10); + + Evas_Object *o; + o = evas_object_image_add(evas_object_evas_get(entry)); + evas_object_image_file_set(o, pi->file, NULL); + if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE) + { + int w = 0, h = 0; + evas_object_image_size_get(o, &w, &h); + + if (w > 200 || h > 150) + { + double divd, tw, th; + if (w > h) + { + divd = (double)200/w; + tw = (double)w*divd; + th = (double)h*divd; + } + else + { + divd = (double)150/h; + tw = (double)w*divd; + th = (double)h*divd; + } + sprintf(imgres, "%dx%d", (int)tw, (int)th); + } + else + { + if (!w || !h) + strcpy(imgres, "240x180"); + else + sprintf(imgres, "%dx%d", w, h); + } + } + else + strcpy(imgres, "240x180"); + evas_object_del(o); + pasteimage_provider_set(entry); pastedimages = eina_list_append(pastedimages, pi); - entrytag = alloca(sizeof(char)*(strlen(tagstring)+strlen(pi->file)+1)); - snprintf(entrytag, (strlen(tagstring)+strlen(pi->file)), tagstring, pi->file); + entrytag = alloca(sizeof(char)*(strlen(tagstring)+strlen(imgres)+strlen(pi->file)+1)); + snprintf(entrytag, (strlen(tagstring)+strlen(imgres)+strlen(pi->file)), tagstring, imgres, pi->file); elm_entry_entry_insert(entry, entrytag); return EINA_TRUE; -- 2.7.4