bugfix [#24287] Saving the render result through the API does not use the scene settings
authorCampbell Barton <ideasman42@gmail.com>
Wed, 27 Oct 2010 22:13:05 +0000 (22:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 27 Oct 2010 22:13:05 +0000 (22:13 +0000)
use scene alpha and dither settings.

source/blender/makesrna/intern/rna_image_api.c

index 74d6110127321c4afd7a6902541ef87fb45a2fee..6e495c5db8e43b1e163fdecebc1fe632c138e91f 100644 (file)
@@ -73,9 +73,17 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
                if (ibuf == NULL) {
                        BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image");
                }
-
-               if (!BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) {
-                       BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path);
+               else {
+                       /* temp swap out the color */
+                       const unsigned char imb_depth_back= ibuf->depth;
+                       const float dither_back= ibuf->dither; 
+                       ibuf->depth= scene->r.planes;
+                       ibuf->dither= scene->r.dither_intensity;
+                       if (!BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) {
+                               BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path);
+                       }
+                       ibuf->depth= imb_depth_back;
+                       ibuf->dither= dither_back;
                }
 
                BKE_image_release_ibuf(image, lock);