diff options
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 82b0d231869..018cd25187a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -242,11 +242,11 @@ void BKE_image_free(Image *ima) } /* only image block itself */ -static Image *image_alloc(const char *name, short source, short type) +static Image *image_alloc(Main *bmain, const char *name, short source, short type) { Image *ima; - ima = BKE_libblock_alloc(&G.main->image, ID_IM, name); + ima = BKE_libblock_alloc(&bmain->image, ID_IM, name); if (ima) { ima->ok = IMA_OK; @@ -323,9 +323,9 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) } /* empty image block, of similar type and filename */ -Image *BKE_image_copy(Image *ima) +Image *BKE_image_copy(Main *bmain, Image *ima) { - Image *nima = image_alloc(ima->id.name + 2, ima->source, ima->type); + Image *nima = image_alloc(bmain, ima->id.name + 2, ima->source, ima->type); BLI_strncpy(nima->name, ima->name, sizeof(ima->name)); @@ -343,6 +343,9 @@ Image *BKE_image_copy(Image *ima) BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings); + if (ima->packedfile) + nima->packedfile = dupPackedFile(ima->packedfile); + return nima; } @@ -433,7 +436,7 @@ void BKE_image_make_local(struct Image *ima) extern_local_image(ima); } else if (is_local && is_lib) { - Image *ima_new = BKE_image_copy(ima); + Image *ima_new = BKE_image_copy(bmain, ima); ima_new->id.us = 0; @@ -568,7 +571,7 @@ static void image_init_color_management(Image *ima) } } -Image *BKE_image_load(const char *filepath) +Image *BKE_image_load(Main *bmain, const char *filepath) { Image *ima; int file, len; @@ -576,7 +579,7 @@ Image *BKE_image_load(const char *filepath) char str[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, bmain->name); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); @@ -589,7 +592,7 @@ Image *BKE_image_load(const char *filepath) while (len > 0 && filepath[len - 1] != '/' && filepath[len - 1] != '\\') len--; libname = filepath + len; - ima = image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima = image_alloc(bmain, libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); BLI_strncpy(ima->name, filepath, sizeof(ima->name)); if (BLI_testextensie_array(filepath, imb_ext_movie)) @@ -631,7 +634,7 @@ Image *BKE_image_load_exists(const char *filepath) } } - return BKE_image_load(filepath); + return BKE_image_load(G.main, filepath); } static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, @@ -691,10 +694,10 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4]) +Image *BKE_image_add_generated(Main *bmain, unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4]) { /* on save, type is changed to FILE in editsima.c */ - Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); + Image *ima = image_alloc(bmain, name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); if (ima) { ImBuf *ibuf; @@ -720,7 +723,7 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf) /* on save, type is changed to FILE in editsima.c */ Image *ima; - ima = image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima = image_alloc(G.main, BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); @@ -2104,7 +2107,7 @@ Image *BKE_image_verify_viewer(int type, const char *name) break; if (ima == NULL) - ima = image_alloc(name, IMA_SRC_VIEWER, type); + ima = image_alloc(G.main, name, IMA_SRC_VIEWER, type); /* happens on reload, imagewindow cannot be image user when hidden*/ if (ima->id.us == 0) |