diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-27 08:24:34 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-27 08:24:34 +0400 |
commit | fa6e6e7fc0977248e7ac10dddc79499304f05bda (patch) | |
tree | 6edd348b5b6654b1939aa9f9da23e52014931e0b /source | |
parent | 31d401613da287d4b867727a5f51f3746edfd334 (diff) |
pass image description to image loading functions for more useful error than 'Unknown fileformat'.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 2 | ||||
-rw-r--r-- | source/blender/blenpluginapi/intern/pluginapi.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 23 | ||||
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 5 | ||||
-rw-r--r-- | source/blender/imbuf/intern/anim_movie.c | 7 | ||||
-rw-r--r-- | source/blender/imbuf/intern/readimage.c | 48 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 2 |
9 files changed, 51 insertions, 50 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d60d32a4a51..ee0f1177fce 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1948,7 +1948,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) flag = IB_rect|IB_multilayer; if(ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag); + ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag, "<packed data>"); } else { flag= IB_rect|IB_multilayer|IB_metadata; diff --git a/source/blender/blenpluginapi/intern/pluginapi.c b/source/blender/blenpluginapi/intern/pluginapi.c index 67d404899b2..b6bd15fd1c3 100644 --- a/source/blender/blenpluginapi/intern/pluginapi.c +++ b/source/blender/blenpluginapi/intern/pluginapi.c @@ -130,7 +130,7 @@ LIBEXPORT short saveiff(struct ImBuf *ib, LIBEXPORT struct ImBuf *loadifffile(int a, int b) { - return IMB_loadifffile(a, b); + return IMB_loadifffile(a, b, "loadifffile"); } LIBEXPORT struct ImBuf *loadiffname(char *n, diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 39f6cb7b0c2..b35e20bfe31 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -462,10 +462,10 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha) static void init_brush_icons(void) { -#define INIT_BRUSH_ICON(icon_id, name) \ - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \ - datatoc_ ##name## _png_size, IB_rect); \ - def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ +#define INIT_BRUSH_ICON(icon_id, name) \ + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \ + datatoc_ ##name## _png_size, IB_rect, "<brush icon>"); \ + def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ IMB_freeImBuf(bbuf); // end INIT_BRUSH_ICON @@ -527,7 +527,7 @@ static void init_internal_icons(void) } } if(bbuf==NULL) - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect); + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect, "<blender icons>"); if(bbuf) { /* free existing texture if any */ diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index bcd35c63a41..e739c5fe22e 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -374,7 +374,7 @@ void filelist_init_icons(void) #ifdef WITH_HEADLESS bbuf = NULL; #else - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect); + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>"); #endif if (bbuf) { for (y=0; y<SPECIAL_IMG_ROWS; y++) { diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5f03ca9ba28..3ab199625a4 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -94,19 +94,20 @@ void IMB_exit(void); * * @attention Defined in readimage.c */ -struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags); +struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, + int flags, const char *descr); /** * * @attention Defined in readimage.c */ -struct ImBuf *IMB_testiffname(char *naam,int flags); +struct ImBuf *IMB_testiffname(const char *filepath, int flags); /** * * @attention Defined in readimage.c */ -struct ImBuf *IMB_loadiffname(const char *naam, int flags); +struct ImBuf *IMB_loadiffname(const char *filepath, int flags); /** * @@ -119,7 +120,7 @@ void IMB_freeImBuf(struct ImBuf *ibuf); * @attention Defined in allocimbuf.c */ struct ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, - unsigned char d, unsigned int flags); + unsigned char d, unsigned int flags); /** * @@ -237,7 +238,7 @@ int IMB_anim_get_fps(struct anim * anim, /** * - * @attention Defined in anim.c + * @attention Defined in anim_movie.c */ struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex); void IMB_close_anim(struct anim *anim); @@ -245,16 +246,16 @@ void IMB_close_anim(struct anim *anim); /** * - * @attention Defined in anim.c + * @attention Defined in anim_movie.c */ -int ismovie(const char *name); +int ismovie(const char *filepath); void IMB_anim_set_preseek(struct anim *anim, int preseek); int IMB_anim_get_preseek(struct anim *anim); /** * - * @attention Defined in anim.c + * @attention Defined in anim_movie.c */ struct ImBuf *IMB_anim_absolute( @@ -264,14 +265,14 @@ struct ImBuf *IMB_anim_absolute( /** * - * @attention Defined in anim.c + * @attention Defined in anim_movie.c * fetches a define previewframe, usually half way into the movie */ struct ImBuf *IMB_anim_previewframe(struct anim *anim); /** * - * @attention Defined in anim.c + * @attention Defined in anim_movie.c */ void IMB_free_anim(struct anim *anim); @@ -419,7 +420,7 @@ struct ImBuf *IMB_loadiffmem(int *mem, int flags); * @deprecated Only here for backwards compatibility of the * @deprecated plugin system. */ -struct ImBuf *IMB_loadifffile(int file, int flags); +struct ImBuf *IMB_loadifffile(int file, int flags, const char *descr); /** * diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 1d82c862dbd..5bbabd84648 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -165,8 +165,6 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_freezbuffloatImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_metadata_free(ibuf); - if (ibuf->dds_data.data != NULL) - free(ibuf->dds_data.data); MEM_freeN(ibuf); } } @@ -448,6 +446,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) return(ibuf2); } +#if 0 /* remove? - campbell */ /* support for cache limiting */ static void imbuf_cache_destructor(void *data) @@ -463,6 +462,7 @@ static void imbuf_cache_destructor(void *data) ibuf->c_handle = NULL; } + static MEM_CacheLimiterC **get_imbuf_cache_limiter(void) { static MEM_CacheLimiterC *c = NULL; @@ -472,3 +472,4 @@ static MEM_CacheLimiterC **get_imbuf_cache_limiter(void) return &c; } +#endif diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index e1592d221fb..3adb9a3791f 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -1,7 +1,4 @@ /* - * anim.c - * - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -113,7 +110,7 @@ #endif #endif -int ismovie(const char *UNUSED(name)) { +int ismovie(const char *UNUSED(filepath)) { return 0; } @@ -372,7 +369,7 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position) { if (anim->pgf) { lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo])); if (lpbi) { - ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect); + ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, "<avi_fetchibuf>"); //Oh brother... } } diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 794777b21d3..c2f73efa63f 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -43,19 +43,20 @@ #endif #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_filetype.h" -ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags) +ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const char *descr) { ImBuf *ibuf; ImFileType *type; if(mem == NULL) { - printf("Error in ibImageFromMemory: NULL pointer\n"); + fprintf(stderr, "%s: NULL pointer\n", __func__); return NULL; } @@ -73,12 +74,12 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags) } } - fprintf(stderr, "Unknown fileformat\n"); - + fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr); + return NULL; } -ImBuf *IMB_loadifffile(int file, int flags) +ImBuf *IMB_loadifffile(int file, int flags, const char *descr) { ImBuf *ibuf; unsigned char *mem; @@ -90,14 +91,14 @@ ImBuf *IMB_loadifffile(int file, int flags) mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0); if(mem==(unsigned char*)-1) { - fprintf(stderr, "Couldn't get mapping\n"); + fprintf(stderr, "%s: couldn't get mapping %s\n", __func__, descr); return NULL; } - ibuf= IMB_ibImageFromMemory(mem, size, flags); + ibuf= IMB_ibImageFromMemory(mem, size, flags, descr); if(munmap(mem, size)) - fprintf(stderr, "Couldn't unmap file.\n"); + fprintf(stderr, "%s: couldn't unmap file %s\n", __func__, descr); return ibuf; } @@ -117,24 +118,24 @@ static void imb_cache_filename(char *filename, const char *name, int flags) BLI_strncpy(filename, name, IB_FILENAME_SIZE); } -ImBuf *IMB_loadiffname(const char *name, int flags) +ImBuf *IMB_loadiffname(const char *filepath, int flags) { ImBuf *ibuf; int file, a; - char filename[IB_FILENAME_SIZE]; + char filepath_tx[IB_FILENAME_SIZE]; - imb_cache_filename(filename, name, flags); + imb_cache_filename(filepath_tx, filepath, flags); - file = open(filename, O_BINARY|O_RDONLY); + file = open(filepath_tx, O_BINARY|O_RDONLY); if(file < 0) return NULL; - ibuf= IMB_loadifffile(file, flags); + ibuf= IMB_loadifffile(file, flags, filepath_tx); if(ibuf) { - BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); - BLI_strncpy(ibuf->cachename, filename, sizeof(ibuf->cachename)); + BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); for(a=1; a<ibuf->miptot; a++) - BLI_strncpy(ibuf->mipmap[a-1]->cachename, filename, sizeof(ibuf->cachename)); + BLI_strncpy(ibuf->mipmap[a-1]->cachename, filepath_tx, sizeof(ibuf->cachename)); if(flags & IB_fields) IMB_de_interlace(ibuf); } @@ -143,21 +144,22 @@ ImBuf *IMB_loadiffname(const char *name, int flags) return ibuf; } -ImBuf *IMB_testiffname(char *name, int flags) +ImBuf *IMB_testiffname(const char *filepath, int flags) { ImBuf *ibuf; int file; - char filename[IB_FILENAME_SIZE]; + char filepath_tx[IB_FILENAME_SIZE]; - imb_cache_filename(filename, name, flags); + imb_cache_filename(filepath_tx, filepath, flags); - file = open(filename,O_BINARY|O_RDONLY); + file = open(filepath_tx,O_BINARY|O_RDONLY); if(file < 0) return NULL; - ibuf=IMB_loadifffile(file, flags|IB_test|IB_multilayer); + ibuf=IMB_loadifffile(file, flags|IB_test|IB_multilayer, filepath_tx); + if(ibuf) { - BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); - BLI_strncpy(ibuf->cachename, filename, sizeof(ibuf->cachename)); + BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); } close(file); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 177a468c008..a817761bd65 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1218,7 +1218,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar extern char datatoc_splash_png[]; extern int datatoc_splash_png_size; - ImBuf *ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect); + ImBuf *ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect, "<splash screen>"); #else ImBuf *ibuf= NULL; #endif |