08-25-2012 12:38 PM
you can find these pieces of code in samples, this works for me:
img_decode_callouts_t Callouts;
img_lib_t ilib = NULL;
img_t img;
char strFileName[]= "yourfilename";
int rc = img_lib_attach(&ilib);
memset(&img, 0, sizeof(img));
memset(&Callouts, 0, sizeof(Callouts));
rc = img_load_file(ilib, strFileName, NULL, &img);
img_lib_detach(ilib);
/* your window should be initialized already*/
_uint8 *ScreenData;
screen_buffer_t screen_buf;
screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);
screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&ScreenData);
for (unsigned int y=0; y < img.h; y++){
memcpy(ScreenData + y*nScreenWidth*nBytesPerPixel, img.access.direct.data + y*img.direct.stride, img.access.direct.stride);
}
int rect[4] = { 0, 0, img.w, img.h };
screen_post_window(screen_win, screen_buf, 1, rect, 0);
08-25-2012 08:10 PM
BGmot wrote:
you can find these pieces of code in samples, this works for me:
img_decode_callouts_t Callouts; img_lib_t ilib = NULL; img_t img; char strFileName[]= "yourfilename"; int rc = img_lib_attach(&ilib); memset(&img, 0, sizeof(img)); memset(&Callouts, 0, sizeof(Callouts)); rc = img_load_file(ilib, strFileName, NULL, &img); img_lib_detach(ilib); /* your window should be initialized already*/ _uint8 *ScreenData; screen_buffer_t screen_buf; screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&ScreenData); for (unsigned int y=0; y < img.h; y++){ memcpy(ScreenData + y*nScreenWidth*nBytesPerPixel, img.access.direct.data + y*img.direct.stride, img.access.direct.stride); } int rect[4] = { 0, 0, img.w, img.h }; screen_post_window(screen_win, screen_buf, 1, rect, 0);
thanks will give it a go.
02-18-2013 10:22 AM
Hello, my name is Joe and am currently work on my 4th year project, i having difficulties with loading multiple images, resizing them and position the on areas on the playbook screen, and how i could use the image as a button, could to please help me out . thank very much
02-18-2013 11:31 AM
- loading images
- resizing them
- position them on areas
are three different tasks. Which one(s) are you having difficulties with? What approach are you taking and what is failing?
02-18-2013 11:48 AM - edited 02-18-2013 12:06 PM
Thanks, i was able load an image,
i want to be able to load multiple images (png)
and i cant resize the image and position them
so i have problem with mainly 2 and 3 listed.
The approach i take was to use the load_image_resize_fiile()
here is the code i have
int load_image(screen_window_t screen_win, const char *path, int x, int y)
{
img_decode_callouts_t callouts;
img_lib_t ilib = NULL;
img_t img;
int rc;
rc = img_lib_attach(&ilib);
if (rc != IMG_ERR_OK) {
return -1;
}
memset(&img, 0, sizeof(img_t));
img.flags |= IMG_FORMAT;
img.format = IMG_FMT_PKLE_XRGB8888;
memset(&callouts, 0, sizeof(callouts));
callouts.setup_f = decode_setup;
callouts.abort_f = decode_abort;
callouts.data = (uintptr_t)screen_win;
img.flags |= IMG_RESIZE;
img.w = x;
img.flags |= IMG_W;
img.h = y;
img.flags |= IMG_H;
rc = img_load_resize_file(ilib, path, &callouts, &img);
img.flags |= IMG_DIRECT;
img_lib_detach(ilib);
return rc == IMG_ERR_OK ? 0 : -1;
}
thanks very much