Fix image save ignoring options
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Jan 2016 07:51:48 +0000 (18:51 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Jan 2016 07:56:23 +0000 (18:56 +1100)
Saving an image didn't un-set previously enabled options.
(saving 16bit png as 8 bit didn't work for eg).

source/blender/blenkernel/intern/image.c

index 7eea53497b2a8c917a1812d442172fc580f69304..55cbf13ed34fbc1b60f3dac212ec3021f12a5727 100644 (file)
@@ -2174,6 +2174,9 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
        char compress = imf->compress;
        char quality = imf->quality;
 
+       /* initialize all from image format */
+       ibuf->foptions.flag = 0;
+
        if (imtype == R_IMF_IMTYPE_IRIS) {
                ibuf->ftype = IMB_FTYPE_IMAGIC;
        }
@@ -2214,7 +2217,6 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
                ibuf->ftype = IMB_FTYPE_OPENEXR;
                if (imf->depth == R_IMF_CHAN_DEPTH_16)
                        ibuf->foptions.flag |= OPENEXR_HALF;
-               ibuf->foptions.flag &= ~OPENEXR_COMPRESS;
                ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
 
                if (!(imf->flag & R_IMF_FLAG_ZBUF))
@@ -2334,6 +2336,7 @@ int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
                /* note that we are not restoring _all_ settings */
                ibuf->planes = ibuf_back.planes;
                ibuf->ftype =  ibuf_back.ftype;
+               ibuf->foptions =  ibuf_back.foptions;
        }
 
        return ok;