diff options
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 30 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 1 |
3 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 2fa2fde681c..64b4d17b17d 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -576,9 +576,9 @@ static void rna_def_image_packed_files(BlenderRNA *brna) prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "filepath"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_struct_name_property(srna, prop); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + RNA_api_image_packed_file(srna); } static void rna_def_render_slot(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index f187a0e1804..1efa41d1b00 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -63,6 +63,14 @@ #include "MEM_guardedalloc.h" +static void rna_ImagePackedFile_save(ImagePackedFile *imapf, ReportList *reports) +{ + if (writePackedFile(reports, imapf->filepath, imapf->packedfile, 0) != RET_OK) { + BKE_reportf(reports, RPT_ERROR, "Image could not save packed file to '%s'", + imapf->filepath); + } +} + static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports, const char *path, Scene *scene) { ImBuf *ibuf; @@ -115,17 +123,10 @@ 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 (BKE_image_has_packedfile(image)) { - ImagePackedFile *imapf; + /* note, we purposefully ignore packed files here, + * developers need to explicitly write them via 'packed_files' */ - 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)) { + if (IMB_saveiff(ibuf, filename, ibuf->flags)) { image->type = IMA_TYPE_IMAGE; if (image->source == IMA_SRC_GENERATED) @@ -295,6 +296,15 @@ static void rna_Image_buffers_free(Image *image) #else +void RNA_api_image_packed_file(StructRNA *srna) +{ + FunctionRNA *func; + + func = RNA_def_function(srna, "save", "rna_ImagePackedFile_save"); + RNA_def_function_ui_description(func, "Save the packed file to its filepath"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); +} + void RNA_api_image(StructRNA *srna) { FunctionRNA *func; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index eab14be9085..72cd2ce55b8 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -260,6 +260,7 @@ void RNA_api_camera(StructRNA *srna); void RNA_api_curve(StructRNA *srna); void RNA_api_fcurves(StructRNA *srna); void RNA_api_drivers(StructRNA *srna); +void RNA_api_image_packed_file(struct StructRNA *srna); void RNA_api_image(struct StructRNA *srna); void RNA_api_lattice(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); |