我试图在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网站的图像文档中尝试,没有专门用于路径设置的信息。
如何添加简单图像并显示?
您可以使用相对文件路径并将图像文件设置为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