如何在tizen原生小部件上设置和显示图像?

问题描述 投票:0回答:1

我试图在tizen原生小部件上设置图像,但我不知道如何检索路径并应用它。以下是我的尝试:

//image
                char full_path[PATH_MAX] = { 0, };
                data_get_resource_path("images/testimg.png", full_path, (int) PATH_MAX); //getting error here.



                    Evas_Object *image;
                    image = elm_image_add(wid->conform);

                    elm_object_item_data_set(image, full_path); //how to set path?

                    elm_image_no_scale_set(image, EINA_TRUE);
                    elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
                    /* Tell the image to keep original aspect ratio */
                    elm_image_aspect_fixed_set(image, EINA_TRUE);
                    /* Then let the image fill the entire object */
                    elm_image_fill_outside_set(image, EINA_TRUE);

                    evas_object_show(image);

从tizen dev网站的图像文档中尝试,没有专门用于路径设置的信息。

如何添加简单图像并显示?

tizen tizen-wearable-sdk tizen-native-app
1个回答
0
投票

您可以使用相对文件路径并将图像文件设置为efl对象。

有许多示例应用程序。例如,BuddyUI Sample Application显示如何获取图像文件路径

图像文件位于res/images/wc_contact_bg.png中。

#define IMAGE_CONTACT_BG "images/wc_contact_bg.png"

static bool app_create(void *user_data)
{
    Evas_Object *win = NULL;
    Eina_List *item_list = NULL;
    Evas_Object *main_view_layout = NULL;
    Evas_Object *naviframe = NULL;
    int item_count = 0;
    int i = 0;
    char default_img_path[PATH_MAX] = { 0, };
    char edj_path[PATH_MAX] = { 0, };

    data_get_resource_path(EDJ_FILE, edj_path, sizeof(edj_path));
    data_get_resource_path(IMAGE_CONTACT_BG, default_img_path, sizeof(default_img_path));

您可以通过app_get_resource_path获取应用程序资源目录的绝对路径。

void data_get_resource_path(const char *file_in, char *file_path_out, int file_path_max)
{
    char *res_path = app_get_resource_path();
    if (res_path) {
        snprintf(file_path_out, file_path_max, "%s%s", res_path, file_in);
        free(res_path);
    }
}

您可以在以下链接中找到大量信息。 File System Directory Hierarchy

© www.soinside.com 2019 - 2024. All rights reserved.