Mercurial > MadButterfly
diff examples/menu/filebrowser.c @ 356:3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
- Application should specify content of sh_image_t by fill the shape
with a paint_image_t.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 09 Mar 2009 23:05:57 +0800 |
parents | 04d22dc38bc0 |
children | 31b6633e3538 |
line wrap: on
line diff
--- a/examples/menu/filebrowser.c Mon Mar 09 01:35:19 2009 +0800 +++ b/examples/menu/filebrowser.c Mon Mar 09 23:05:57 2009 +0800 @@ -68,24 +68,26 @@ void mypreview(MyAppData *data, char *path) { redraw_man_t *rdman = MBAPP_RDMAN(myApp); - mb_img_ldr_t *ldr = rdman_img_ldr(rdman); - mb_img_data_t *img = MB_IMG_LDR_LOAD(ldr, path); + paint_t *paint, *old_paint; + paint_t *previewimg_paint; shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg"); - mb_img_data_t *previewimg_img_data; - mb_img_data_t *old_img; + int w, h; - previewimg_img_data = - (mb_img_data_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite, - "previewimg_img_data"); + previewimg_paint = + (paint_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite, + "previewimg_paint_img"); printf("Preview %s\n",path); - if (img) { - printf("image %d %d\n",img->w,img->h); - old_img = sh_image_get_img_data(obj); - sh_image_set_img_data(obj,img); - if(old_img != previewimg_img_data) - MB_IMG_DATA_FREE(old_img); - rdman_shape_changed(MBAPP_RDMAN(myApp),obj); - rdman_redraw_changed(MBAPP_RDMAN(myApp)); + paint = rdman_img_ldr_load_paint(rdman, path); + if (paint) { + paint_image_get_size(paint, &w, &h); + printf("image %d %d\n",w, h); + old_paint = sh_get_fill(obj); + rdman_paint_fill(rdman, paint, obj); + if(old_paint != previewimg_paint) + rdman_paint_free(rdman, old_paint); + + rdman_shape_changed(MBAPP_RDMAN(myApp),obj); + rdman_redraw_changed(MBAPP_RDMAN(myApp)); } }