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/editors
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/editors')
-rw-r--r--source/blender/editors/space_image/image_ops.c54
1 files changed, 1 insertions, 53 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 8fa63fe30a3..62c649ca5d4 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2569,14 +2569,10 @@ void IMAGE_OT_invert(wmOperatorType *ot)
static bool image_pack_test(bContext *C, wmOperator *op)
{
Image *ima = CTX_data_edit_image(C);
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
if (!ima) {
return 0;
}
- if (!as_png && BKE_image_has_packedfile(ima)) {
- return 0;
- }
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported");
@@ -2590,19 +2586,12 @@ static int image_pack_exec(bContext *C, wmOperator *op)
{
struct Main *bmain = CTX_data_main(C);
Image *ima = CTX_data_edit_image(C);
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
if (!image_pack_test(C, op)) {
return OPERATOR_CANCELLED;
}
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
- return OPERATOR_CANCELLED;
- }
-
- if (as_png) {
+ if (BKE_image_is_dirty(ima)) {
BKE_image_memorypack(ima);
}
else {
@@ -2611,46 +2600,9 @@ static int image_pack_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
return OPERATOR_FINISHED;
}
-static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Image *ima = CTX_data_edit_image(C);
- ImBuf *ibuf;
- uiPopupMenu *pup;
- uiLayout *layout;
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
-
- if (!image_pack_test(C, op)) {
- return OPERATOR_CANCELLED;
- }
-
- ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- pup = UI_popup_menu_begin(C, IFACE_("OK"), ICON_QUESTION);
- layout = UI_popup_menu_layout(pup);
- uiItemBooleanO(layout,
- IFACE_("Can't pack edited image from disk, pack as internal PNG?"),
- ICON_NONE,
- op->idname,
- "as_png",
- 1);
- UI_popup_menu_end(C, pup);
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- return OPERATOR_INTERFACE;
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- return image_pack_exec(C, op);
-}
-
void IMAGE_OT_pack(wmOperatorType *ot)
{
/* identifiers */
@@ -2660,13 +2612,9 @@ void IMAGE_OT_pack(wmOperatorType *ot)
/* api callbacks */
ot->exec = image_pack_exec;
- ot->invoke = image_pack_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean(ot->srna, "as_png", 0, "Pack As PNG", "Pack image as lossless PNG");
}
/********************* unpack operator *********************/