Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-06-29 18:10:42 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-06-29 18:10:42 +0300
commit58d6cbba6da31db8dc8a2b42d528b9a353081904 (patch)
tree04b57a2f809c6f08d84a082edf061f3ece631860 /source/blender/makesrna/intern/rna_image_api.c
parent94549adec4b6857fb6ec4cf77606da51ff7c26b7 (diff)
parent295d0c52a26730edc6d4ed1276e4051cce006be5 (diff)
Merge branch 'master' into temp-ghash-setopstemp-ghash-setops
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index b9a1237c1f2..c3c152a10b6 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -56,7 +56,6 @@
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
-#include "BIF_gl.h"
#include "GPU_draw.h"
#include "GPU_debug.h"
@@ -117,9 +116,14 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
BLI_strncpy(filename, image->name, sizeof(filename));
BLI_path_abs(filename, ID_BLEND_PATH(bmain, &image->id));
- if (image->packedfile) {
- if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) {
- BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'", image->id.name + 2, image->name);
+ if (BKE_image_has_packedfile(image)) {
+ ImagePackedFile *imapf;
+
+ for (imapf = image->packedfiles.first; imapf; imapf = imapf->next) {
+ if (writePackedFile(reports, imapf->filepath, imapf->packedfile, 0) != RET_OK) {
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'",
+ image->id.name + 2, imapf->filepath);
+ }
}
}
else if (IMB_saveiff(ibuf, filename, ibuf->flags)) {
@@ -154,20 +158,17 @@ static void rna_Image_pack(
BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
}
else {
- if (image->packedfile) {
- freePackedFile(image->packedfile);
- image->packedfile = NULL;
- }
+ BKE_image_free_packedfiles(image);
if (as_png) {
BKE_image_memorypack(image);
}
else if (data) {
char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);
memcpy(data_dup, data, (size_t)data_len);
- image->packedfile = newPackedFileMemory(data_dup, data_len);
+ BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
}
else {
- image->packedfile = newPackedFile(reports, image->name, ID_BLEND_PATH(bmain, &image->id));
+ BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
}
}
@@ -177,7 +178,7 @@ static void rna_Image_pack(
static void rna_Image_unpack(Image *image, ReportList *reports, int method)
{
- if (!image->packedfile) {
+ if (!BKE_image_has_packedfile(image)) {
BKE_report(reports, RPT_ERROR, "Image not packed");
}
else if (BKE_image_is_animated(image)) {
@@ -288,6 +289,11 @@ static void rna_Image_filepath_from_user(Image *image, ImageUser *image_user, ch
BKE_image_user_file_path(image_user, image, filepath);
}
+static void rna_Image_buffers_free(Image *image)
+{
+ BKE_image_free_buffers(image);
+}
+
#else
void RNA_api_image(StructRNA *srna)
@@ -374,6 +380,9 @@ void RNA_api_image(StructRNA *srna)
RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
RNA_def_function_output(func, parm);
+ func = RNA_def_function(srna, "buffers_free", "rna_Image_buffers_free");
+ RNA_def_function_ui_description(func, "Free the image buffers from memory");
+
/* TODO, pack/unpack, maybe should be generic functions? */
}