Languages

Menu
Sites
Language
Image zooming in tizen 2.3 native application
My native application i am using image that is fitted in full screen. how to implement the image zooming option following code will be i used static void bg_mango_tree_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *bg; Evas_Object *nf = data; char buf[PATH_MAX]; bg = elm_bg_add(nf); elm_bg_option_set(bg, ELM_BG_OPTION_STRETCH); snprintf(buf, sizeof(buf), "%s/*", ICON_DIR); elm_bg_file_set(bg, buf, NULL); elm_naviframe_item_push(nf, "*", NULL, NULL,bg, NULL); }

Responses

14 Replies
Alex Ashirov

Hi,

Could you please describe your requirements in more details? What behavior do you need? You code snippet will just display stretched image.

ezhilarasan b

hi,

exactly it will display stretched image.... how can i add image  zooming widget for the above code...

Alex Dem

Hi,
You could use photocam widget to set zoom level:
https://developer.tizen.org/documentation/mobile-native-app-programming/programming-guide/ui-creating-application-ui/widgets/photocam-widget

code snippet:

    Evas_Object *nf = data;
    Evas_Object *photocam;
    photocam = elm_photocam_add(nf);
    elm_photocam_file_set(photocam, "/tmp/Desert.jpg");
    elm_naviframe_item_push(nf, "Image - Zoom", NULL, NULL, photocam, NULL);

    elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
    elm_photocam_zoom_set(photocam, 0.5);// value smaller than 1, to increase
//    elm_photocam_zoom_set(photocam, 2); //value bigger than 1, to decrease

Alexey.

Alex Dem

To allow multitouch zoom it is enough to add : elm_photocam_gesture_enabled_set(photocam, EINA_TRUE); just.
Alexey.

ezhilarasan b

hi alex dem,

kindly i tried this code but it does not fetch the image from source and screen will appear empty

code:

static void
photocam_mango_tree_cb(void *data, Evas_Object *obj, void *event_info)
{

    Evas_Object *nf = data;
        Evas_Object *photocam;

        photocam = elm_photocam_add(nf);
        elm_photocam_file_set(photocam,"res/images/acid.jpg");
        elm_naviframe_item_push(nf, "acid", NULL, NULL, photocam, NULL);
        elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
        elm_photocam_zoom_set(photocam, 0.5);

}

 

colin Rao

Seems it's the image path issue. I've tested your code on my local test demo project, it works fine, just change the file path as below

elm_photocam_file_set(photocam, "/opt/usr/apps/org.tizen.test/res/images/mango.jpg");

 

colin Rao

but, seems the elm_photocam_zoom_set is not working, maybe I am wrong.

the actually result(from the ui layout) are the same, when I set the zoom factor from 0.5 to 1.0/1.5/2.0

ezhilarasan b
now its working fine... issues in path only thank you
venkadesh P

hai refer the tizen document 2.3 below the link:

https://developer.tizen.org/documentation/dev-guide/2.3.0

Prakash M

Hello Mr.venkadesh.

  Do u know solution for this post.. Why you wasting our time by giving like this useless reference link..

Alex Dem

Hi,
You don't need to set zoom manually using elm_photocam_zoom_mode_set & elm_photocam_zoom_set. It is enoght to add elm_photocam_gesture_enabled_set(photocam, EINA_TRUE); instead of to acheive zoom functionality. I have checked with image with big size.
Alexey.

Alex Dem

Hi,
You don't need to set zoom manually using elm_photocam_zoom_mode_set & elm_photocam_zoom_set. It is enoght to add elm_photocam_gesture_enabled_set(photocam, EINA_TRUE); instead of to acheive zoom functionality. I have checked with image with big size.
Alexey.

colin Rao

Hi, thanks!

it's works fine after I use elm_photocam_gesture_enabled_set(photocam, EINA_TRUE); to replace the elm_photocam_zoom_mode_set & elm_photocam_zoom_set.

I can zoom in/out the image on device by touch guesture.

Shawn Lee

Hi all, 

I got similar problem about photocam widget while zooming in/out images on my test app.

I've already applied elm_photocam_gesture_enabled_set(photocam, EINA_TRUE) on my test project and it works fine. 

By the way, photocam widget size becomes zero when I try to zoom in/out images in case that I put the widget into a box widget. 

As you may see the source code as below, the test project was derived from gallery sample and I replaced image widget with photocam. 

In this regard, please let me know how to solve this problem. 

 

 

///////////////// main.c

#include <tizen.h>
#include "photocamsample.h"

const int IMAGE_MAX = 2;

typedef struct appdata {
    Evas_Object *win;
    Evas_Object *conform;
    Evas_Object *nf;
    Evas_Object *layout;
    Evas_Object *scroller;
    Evas_Object *photocams[IMAGE_MAX];
} appdata_s;

static void
win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
{
    ui_app_exit();
}

static void
win_back_cb(void *data, Evas_Object *obj, void *event_info)
{
    appdata_s *ad = data;
    /* Let window go to hide state. */
    elm_win_lower(ad->win);
}


static void
layout_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
    appdata_s *ad = data;
    Evas_Coord w, h;
    int i;

    evas_object_geometry_get(obj, NULL, NULL, &w, &h);

    for(i = 0; i < IMAGE_MAX; i++) {
        evas_object_size_hint_min_set(ad->photocams[i], w, h);
    }

    elm_scroller_page_size_set(ad->scroller, w, h);
}

static void
create_base_gui(appdata_s *ad)
{
    /* Window */
    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);

    /* Conformant */
    ad->conform = elm_conformant_add(ad->win);
    elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
    elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);
    evas_object_show(ad->conform);

    /* Naviframe */
    ad->nf = elm_naviframe_add(ad->conform);
    elm_object_content_set(ad->conform, ad->nf);
    evas_object_show(ad->nf);

    /* layout */
    ad->layout = elm_layout_add(ad->nf);
    evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_event_callback_add(ad->layout, EVAS_CALLBACK_RESIZE, layout_resize_cb, ad);
    elm_layout_theme_set(ad->layout, "layout", "application", "default");
    evas_object_show(ad->layout);

    elm_naviframe_item_push(ad->nf, "Gallery", NULL, NULL, ad->layout, NULL);

    /* Create Scroller */
    ad->scroller = elm_scroller_add(ad->layout);
    elm_scroller_loop_set(ad->scroller, EINA_FALSE, EINA_FALSE);
    evas_object_size_hint_weight_set(ad->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(ad->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_scroller_policy_set(ad->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
    elm_scroller_page_scroll_limit_set(ad->scroller, 0, 1);
    elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->scroller);

    /* Create Box */

    Evas_Object* box = elm_box_add(ad->scroller);
    elm_box_horizontal_set(box, EINA_FALSE);
    elm_object_content_set(ad->scroller, box);
    evas_object_show(box);


    /* Create Pages */
    const char* ICON_DIR = "/opt/usr/apps/org.tizen.photocamsample/res/images";
    char buf[PATH_MAX];
    for(int i = 0; i < IMAGE_MAX; i++) {

        Evas_Object* img = elm_photocam_add(box);
        elm_photocam_gesture_enabled_set(img, EINA_TRUE);
        snprintf(buf, sizeof(buf), "%s/%d.jpg", ICON_DIR, i);
        elm_photocam_file_set(img, buf);
        evas_object_show(img);

        elm_box_pack_end(box, img);

        ad->photocams[i] = img;
    }

    /* Show window after base gui is set up */
    evas_object_show(ad->win);
}

static bool
app_create(void *data)
{
    appdata_s *ad = data;

    create_base_gui(ad);

    return true;
}

static void
app_control(app_control_h app_control, void *data)
{
    /* Handle the launch request. */
}

static void
app_pause(void *data)
{
    /* Take necessary actions when application becomes invisible. */
}

static void
app_resume(void *data)
{
    /* Take necessary actions when application becomes visible. */
}

static void
app_terminate(void *data)
{
    /* Release all resources. */
}

static void
ui_app_lang_changed(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_LANGUAGE_CHANGED*/
    char *locale = NULL;
    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
    elm_language_set(locale);
    free(locale);
    return;
}

static void
ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
    return;
}

static void
ui_app_region_changed(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_REGION_FORMAT_CHANGED*/
}

static void
ui_app_low_battery(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_LOW_BATTERY*/
}

static void
ui_app_low_memory(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_LOW_MEMORY*/
}

int
main(int argc, char *argv[])
{
    appdata_s ad = {0,};
    int ret = 0;

    ui_app_lifecycle_callback_s event_callback = {0,};
    app_event_handler_h handlers[5] = {NULL, };

    event_callback.create = app_create;
    event_callback.terminate = app_terminate;
    event_callback.pause = app_pause;
    event_callback.resume = app_resume;
    event_callback.app_control = app_control;

    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
    ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
    ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
    ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
    ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);

    ret = ui_app_main(argc, argv, &event_callback, &ad);
    if (ret != APP_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
    }

    return ret;
}