[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28333] trunk/blender: Save a Copy, ( operator option for save as),
Campbell Barton
ideasman42 at gmail.com
Wed Apr 21 21:14:21 CEST 2010
Revision: 28333
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28333
Author: campbellbarton
Date: 2010-04-21 21:14:20 +0200 (Wed, 21 Apr 2010)
Log Message:
-----------
Save a Copy, (operator option for save as),
Too many times we have images in blend files that are just saved renders.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_image.py
trunk/blender/source/blender/editors/space_image/image_ops.c
Modified: trunk/blender/release/scripts/ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/ui/space_image.py 2010-04-21 18:13:26 UTC (rev 28332)
+++ trunk/blender/release/scripts/ui/space_image.py 2010-04-21 19:14:20 UTC (rev 28333)
@@ -111,6 +111,7 @@
layout.operator("image.save")
layout.operator("image.save_as")
+ layout.operator("image.save_as", text="Save a Copy").copy = True
if ima.source == 'SEQUENCE':
layout.operator("image.save_sequence")
Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c 2010-04-21 18:13:26 UTC (rev 28332)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c 2010-04-21 19:14:20 UTC (rev 28333)
@@ -823,6 +823,8 @@
if (ibuf) {
int relative= RNA_boolean_get(op->ptr, "relative_path");
+ int save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
+
BLI_path_abs(path, G.sce);
if(scene->r.scemode & R_EXTENSION) {
@@ -845,13 +847,14 @@
if(relative)
BLI_path_rel(path, G.sce); /* only after saving */
- BLI_strncpy(ima->name, path, sizeof(ima->name));
- BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
-
- /* should be function? nevertheless, saving only happens here */
- for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
- ibuf->userflags &= ~IB_BITMAPDIRTY;
-
+ if(!save_copy) {
+ BLI_strncpy(ima->name, path, sizeof(ima->name));
+ BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
+
+ /* should be function? nevertheless, saving only happens here */
+ for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
+ }
}
else
BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image");
@@ -863,36 +866,39 @@
if(relative)
BLI_path_rel(path, G.sce); /* only after saving */
- BLI_strncpy(ima->name, path, sizeof(ima->name));
- BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
-
- ibuf->userflags &= ~IB_BITMAPDIRTY;
-
- /* change type? */
- if(ima->type==IMA_TYPE_R_RESULT) {
- ima->type= IMA_TYPE_IMAGE;
+ if(!save_copy) {
- /* workaround to ensure the render result buffer is no longer used
- * by this image, otherwise can crash when a new render result is
- * created. */
- if(ibuf->rect && !(ibuf->mall & IB_rect))
- imb_freerectImBuf(ibuf);
- if(ibuf->rect_float && !(ibuf->mall & IB_rectfloat))
- imb_freerectfloatImBuf(ibuf);
- if(ibuf->zbuf && !(ibuf->mall & IB_zbuf))
- IMB_freezbufImBuf(ibuf);
- if(ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat))
- IMB_freezbuffloatImBuf(ibuf);
+ BLI_strncpy(ima->name, path, sizeof(ima->name));
+ BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
+
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
+
+ /* change type? */
+ if(ima->type==IMA_TYPE_R_RESULT) {
+ ima->type= IMA_TYPE_IMAGE;
+
+ /* workaround to ensure the render result buffer is no longer used
+ * by this image, otherwise can crash when a new render result is
+ * created. */
+ if(ibuf->rect && !(ibuf->mall & IB_rect))
+ imb_freerectImBuf(ibuf);
+ if(ibuf->rect_float && !(ibuf->mall & IB_rectfloat))
+ imb_freerectfloatImBuf(ibuf);
+ if(ibuf->zbuf && !(ibuf->mall & IB_zbuf))
+ IMB_freezbufImBuf(ibuf);
+ if(ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat))
+ IMB_freezbuffloatImBuf(ibuf);
+ }
+ if( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
+ ima->source= IMA_SRC_FILE;
+ ima->type= IMA_TYPE_IMAGE;
+ }
+
+ name = BLI_last_slash(path);
+
+ /* name image as how we saved it */
+ rename_id(&ima->id, name ? name + 1 : path);
}
- if( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
- ima->source= IMA_SRC_FILE;
- ima->type= IMA_TYPE_IMAGE;
- }
-
- name = BLI_last_slash(path);
-
- /* name image as how we saved it */
- rename_id(&ima->id, name ? name + 1 : path);
}
else
BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", path);
@@ -991,6 +997,7 @@
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE);
RNA_def_boolean(ot->srna, "relative_path", 0, "Relative Path", "Save image with relative path to current .blend file");
+ RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
}
/******************** save image operator ********************/
More information about the Bf-blender-cvs
mailing list