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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-20 16:52:36 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-04-18 21:07:55 +0300
commit64bcdd65bf0727c5e39ac2b3f32bf897bfbf07a1 (patch)
tree1deb0d53867356cab6feecb0fa2f62c44ad88899 /source/blender/makesrna/intern/rna_image_api.c
parent690ed63eb55d1c52b051d8ce40e76e1b57291f29 (diff)
Images: support packing edited images as OpenEXR or PNG.
This way float and multilayer images can now be packed without data loss. This removes the as_png option and always uses the appropriate file format depending on the image contents.
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index b0030a87dfa..ca75f862b11 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -146,35 +146,23 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
-static void rna_Image_pack(Image *image,
- Main *bmain,
- bContext *C,
- ReportList *reports,
- bool as_png,
- const char *data,
- int data_len)
+static void rna_Image_pack(
+ Image *image, Main *bmain, bContext *C, ReportList *reports, const char *data, int data_len)
{
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
+ BKE_image_free_packedfiles(image);
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
+ if (data) {
+ char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);
+ memcpy(data_dup, data, (size_t)data_len);
+ BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
+ }
+ else if (BKE_image_is_dirty(image)) {
+ BKE_image_memorypack(image);
}
else {
- 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);
- BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
- }
- else {
- BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
- }
+ BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
}
- BKE_image_release_ibuf(image, ibuf, NULL);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
@@ -339,8 +327,6 @@ void RNA_api_image(StructRNA *srna)
func = RNA_def_function(srna, "pack", "rna_Image_pack");
RNA_def_function_ui_description(func, "Pack an image as embedded data into the .blend file");
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- RNA_def_boolean(
- func, "as_png", 0, "as_png", "Pack the image as PNG (needed for generated/dirty images)");
parm = RNA_def_property(func, "data", PROP_STRING, PROP_BYTESTRING);
RNA_def_property_ui_text(parm, "data", "Raw data (bytes, exact content of the embedded file)");
RNA_def_int(func,