11-24-2011 02:36 PM
I am very confused on how to load this.
I understand the documentations code:
img_lib_t ilib = NULL; int rc; rc = img_lib_attach(&ilib);
How do I attach img_codec_png.so so it doesnt give me a undefined reference error. I am a bit confused on what the documentation says on the config file in reference to this funtion.
I am trying to insert it into the main function for a learning file I have been working on. If I solve this I believe it will help me with the img_load_file() error im recieving. The working code is below that will give you a black parent window and groups a child window to it. The child is not defined or pushed to the screen yet.(Excuse the if case funtions, trying to practice smart coding practices.)
#include <screen/screen.h>
#include <stdlib.h>
#include <stdio.h>
#include <img/img.h>
screen_context_t homeContext = 0;
screen_window_t homeWindow = 0;//parent window
static const char *homeGroup = "Home Windows";
screen_buffer_t homeBuffer;
int hformat_w = SCREEN_FORMAT_RGBA8888;
int husage_w = SCREEN_USAGE_NATIVE;
int hvis = 0;
int hcolor = 0xff000000;
int hshap[4] = {0, 0, 1, 1};
int hdims[2] = {0, 0};
int hcount = 0;
screen_window_t hcscreen_w = 0;//child window
int main()
{
if(screen_create_context(&homeContext, SCREEN_APPLICATION_CONTEXT) != 0)
{
return EXIT_FAILURE;
}
if(screen_create_window(&homeWindow, homeContext) != 0)
{
screen_destroy_context(homeContext);
return EXIT_FAILURE;
}
if(screen_create_window_group(homeWindow, homeGroup) != 0)
{
return EXIT_FAILURE;
}
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_FORMAT, &hformat_w) != 0)
{
return EXIT_FAILURE;
}
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_USAGE, &husage_w) != 0)
{
return EXIT_FAILURE;
}
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_VISIBLE, &hvis) != 0)
{
return EXIT_FAILURE;
}
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_BUFFER_SIZE, hshap+2) != 0)
{
return EXIT_FAILURE;
}
screen_get_context_property_iv(homeContext, SCREEN_PROPERTY_DISPLAY_COUNT, &hcount);
screen_display_t *hdisps = calloc(hcount, sizeof(screen_display_t));
screen_get_context_property_pv(homeContext, SCREEN_PROPERTY_DISPLAYS, (void **)hdisps);
screen_display_t hdisp = hdisps[0];
free(hdisps);
screen_get_display_property_iv(hdisp, SCREEN_PROPERTY_SIZE, hdims);
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_COLOR, &hcolor) != 0)
{
return EXIT_FAILURE;
}
if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_SOURCE_SIZE, hdims) != 0)
{
return EXIT_FAILURE;
}
int hpos[2] = { -hdims[0], -hdims[1] };
screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_SOURCE_POSITION, hpos);
if(screen_create_window_buffers(homeWindow, 1) != 0)
{
return EXIT_FAILURE;
}
screen_get_window_property_pv(homeWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&homeBuffer);
screen_post_window(homeWindow, homeBuffer, 1, hshap, 0);
if(screen_create_context(&homeContext, SCREEN_APPLICATION_CONTEXT) != 0)
{
return EXIT_FAILURE;
}
if(screen_create_window_type(&hcscreen_w, homeContext, SCREEN_CHILD_WINDOW) != 0)
{
screen_destroy_context(homeContext);
return EXIT_FAILURE;
}
if(screen_join_window_group(hcscreen_w, homeGroup))
{
return EXIT_FAILURE;
}
if(screen_destroy_window(homeWindow) != 0)
{
return EXIT_FAILURE;
}
if(screen_destroy_context(homeContext) != 0)
{
return EXIT_FAILURE;
}
return 0;
}
Solved! Go to Solution.
11-24-2011 08:54 PM
I understand how the img_lib_t points the config file to ilib variable. This still wont work, I have the the nutrino img.h header included. The error I keep getting makes it seem like the file or library isnt there. Any suggestions???
11-30-2011 01:13 PM
You need to link against libimg. Add "img" to your list of libraries.
11-30-2011 01:41 PM
Thank you very much. Your answer makes sense to my belief something isnt being included.
Now for the beginers question how do I add this link to the library, sorry. I am not able to try this out currently perhaps later but I would assum I simply add the lin "-l img" after clicking the new button in linked libraries?
11-30-2011 01:48 PM
Under Project->Properties:
C/C++ Build
Settings
QCC Linker
Libraries
Click the + and add "img"
11-30-2011 02:24 PM
Dont have my playbook to test simlation but ide recognizes the load funtion! Thanks!!!