语言

Menu
Sites
Language
How to include a raw image file into build output folder

I have a head_32.png file in /res/images/, I want to use this image file in .c file, as the code

    Evas_Object *bg = elm_bg_add(obj);
    char buf[PATH_MAX];
    snprintf(buf, sizeof(buf), "%s/head_32.png", ICON_DIR);
    elm_bg_file_set(bg, buf, NULL);


#define ICON_DIR "/opt/usr/apps/org.tizen.myweixin/res/images"

The actually result is the bg set is unsuccess, I can't see the background image. 

Also, I've checked my Debug folder(the building output folder), there is no images folder in its sub folder res.

I am used the Tizen SDK 2.3, did anybody know how to solve this issue?

响应

10 回复
Alex Ashirov

Hi,

Did you check /Debug/res/ folder or /Debug/.tpk/res ?

colin Rao

Yes, I've checked the /Debug/res folder, there's no such images folde under it. 

Also, I've checked the /Debug/*.tpk folder, I can see the /res/images/head_32.png file. But I don't know why I can't set the bg file success? 

Alex Ashirov

Hi,

What is value returned by elm_bg_file_set()? If it’s true then you can also try to play with elm_bg_option_set() function.

colin Rao

Hi, thanks! I'll try it.

btw, currently, I am used another way as the code,

    if (strcmp(part, "elm.swallow.icon") == 0) {
        char filename[PATH_MAX];
        Evas_Object *ic = elm_icon_add(obj);
        snprintf(filename, sizeof(filename), "%s%s", ICON_DIR, "head_32.png");
        elm_image_file_set(ic, filename, NULL);
        evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
        return ic;
    }

 

colin Rao

Hi, I've tried. Only the ELM_BG_OPTION_CENTER option can works.

        Evas_Object *bg = elm_bg_add(obj);
        char buf[PATH_MAX];
        snprintf(buf, sizeof(buf), "%s%s", ICON_DIR, "head_32.png");
        elm_bg_file_set(bg, buf, NULL);
        elm_bg_option_set(bg, ELM_BG_OPTION_CENTER);

What's the problem?

colin Rao

Additional info, this bg object is used to add an icon for the genlist widget's item, the left icon, swallow part "elm.swallow.icon".

Alex Ashirov

Hi,

It seems that there are some real problems with the Background API. I have just checked UI Controls sample delivered with the SDK and I can observe that bg related samples show empty windows instead of centered, scaled and stretched images. 

Alex Ashirov

Hi,

I have fixed the issue mentioned above. I just copied logo.png file from

\UI Controls(elementary)\project\edje\images

to

\UI Controls(elementary)\project\res\images

Now the sample works fine and can be useful to understand how the Background API works.

colin Rao

Hi, thanks!

I my local app environment, I've also put the image under the res\images folder, the actually result as my previous comment "BY colin Rao, 15 Jan 2015, 23:15".

Alex Ashirov

Hi,

If this APIs work fine in the UI Controls sample then they should work in your application. You can use the sample to figure out what is wrong in your application. You can try to replace your image with logo.png from the sample to make sure that your image is not wrong. Also, you can check that path provided to elm_bg_file_set() is the same as the path in the sample. One more idea is to try to replace logo.png in the sample with your head_32.png image.