Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - load and display an image using the 'libimg' library and the "QNX Screen" API.: (1 Item)
   
load and display an image using the 'libimg' library and the "QNX Screen" API.  
Hi, 

I am a beginner in leaning QNX. I just have an assignment to load and display an image using the image library "libimg" 
and the "QNX Screen" API. 

I created my code based on the sample code given in http://support7.qnx.com/download/downlo ... _Guide.pdf, also the 
sample code given in the post https://github.com/blackberry/NDK-Sampl ... ure/main.c. My code is below (omit all print 
code for debugging):

static img_t img;
screen_context_t screen_context;
screen_window_t screen_window;

int main(int argc, char * const argv[]) {
screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT);
screen_create_window(&screen_window, screen_context);

int count = 0;
screen_get_context_property_iv(screen_context,SCREEN_PROPERTY_DISPLAY_COUNT, &count);
screen_display_t *screen_disps = calloc(count, sizeof(screen_display_t));
screen_get_context_property_pv(screen_context, SCREEN_PROPERTY_DISPLAYS,	(void **) screen_disps);
screen_display_t screen_disp = screen_disps[0];
free(screen_disps);

int vis = 1;
int dims[2] = { 512, 512 };
int rect[4] = { 0, 0, 1, 1 };
screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_VISIBLE, &vis);
screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_BUFFER_SIZE,rect + 2);
rev = screen_set_window_property_iv(screen_window,SCREEN_PROPERTY_SOURCE_SIZE, dims);

screen_buffer_t screen_buf;
screen_create_window_buffers(screen_window, 1);
screen_get_window_property_pv(screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);

screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&img.access.direct.data);
screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, (int *)&img.access.direct.stride);
img.flags |= IMG_DIRECT;

loadImg();
screen_post_window(screen_window, screen_buf, 1, rect, 0);

}

static void loadImg(void) {
img_lib_t ilib = NULL;
int rc1 = 0;
img_lib_attach(&ilib);
img.w = 512;
img.flags |= IMG_W;
img.h = 512;
img.flags |= IMG_H;
rc1 == img_load_file(ilib,filename , NULL, &img);
img_lib_detach(ilib);
}

The debug info shows that loading image is successful, however what I can see is a 512*512 white image on my screen. I 
don't know what is the problem, hope I can get some help here. 

Thank you very much.

Lila