언어 설정

Menu
Sites
Language
Image resource and paths

Hi

I am new to native developement and I have some questions related to resources and its paths. For example I've created an background and want to set an image for it. I've placed the  image into res/images, but I am struggling to get it to work. Do I have to include the image somewhere explicit? What's the path to that resource? I've tried with /opt/usr/apps/org.hue.widget/res/images, but that seems not to work

답변 바로가기

Responses

4 댓글
woochan lee

Hello.

Please check your application ID in .xml file.

 

If your application ID is "org.example.uicomponents"

your image path must be "/opt/usr/apps/org.example.uicomponents/res/images"

 

otherwise you can use "app_get_resource_path()" API for it.

 

hope you got solution.

Mark as answer
Alex Dem

Hi,
In almost every Native Sample there is presented some method like:

static void
app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max)
{
    char *res_path = app_get_resource_path();
    if (res_path) {
        snprintf(edj_path_out, edj_path_max, "%s%s", res_path, edj_file_in);
        free(res_path);
    }
}


and you could use it to get your image path.

Image could be located at projectDir/res/images/image_1.jpg before and defined with:

#define IMAGE_PATH "images/image_1.jpg"

So you could it to get your image path, .
 

char image_path[PATH_MAX] = {0, };
//...
app_get_resource(IMAGE_PATH, image_path, (int)PATH_MAX);

Alexey.

Philippe Wechsler

Thank you, the app_get_resource_path() pointed it out. The app is a widget, so the path is not "/opt/usr/apps[App id]/res/images" but "/opt/usr/apps/[Package ID of the Host app]/res/images" instead.

Alex Dem

Hi,
also fyi,
if you want to use images in edc markup of UI app as:

    images {
        image: "some_image.png" COMP;
    }

you should place them projectDir/edje/images
Alexey.