Fix T52334: images with non-color data should not change color space on save.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 10 Aug 2017 12:11:18 +0000 (14:11 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 10 Aug 2017 13:49:17 +0000 (15:49 +0200)
source/blender/imbuf/intern/colormanagement.c
source/blender/imbuf/intern/jp2.c
source/blender/imbuf/intern/png.c
source/blender/imbuf/intern/tiff.c

index 03f71b5878c35777ba196c6e5e03898f2d547111..1f3be8d73bbace2b464e720ca53062524a07061b 100644 (file)
@@ -2565,6 +2565,14 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index)
 
 void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
 {
+       /* Don't modify non-color data space, it does not change with file type. */
+       ColorSpace *colorspace = colormanage_colorspace_get_named(colorspace_settings->name);
+
+       if (colorspace && colorspace->is_data) {
+               return;
+       }
+
+       /* Get color space from file type. */
        const ImFileType *type;
 
        for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
index 390f2502ee77f38aededd038e543ef5886d623fe..388c2734fe9464811bb3dcef5f02ccdc76ae8d03 100644 (file)
@@ -588,7 +588,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
        img_fol_t img_fol; /* only needed for cinema presets */
        memset(&img_fol, 0, sizeof(img_fol_t));
        
-       if (ibuf->float_colorspace) {
+       if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
                /* float buffer was managed already, no need in color space conversion */
                chanel_colormanage_cb = channel_colormanage_noop;
        }
index 503e63a3fb189f1904f2c9d3dbad3fc5297d7f94..dded0f7aecf718e7ef8a73e4fa51bc277db8714b 100644 (file)
@@ -152,7 +152,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
        compression = (int)(((float)(ibuf->foptions.quality) / 11.1111f));
        compression = compression < 0 ? 0 : (compression > 9 ? 9 : compression);
 
-       if (ibuf->float_colorspace) {
+       if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
                /* float buffer was managed already, no need in color space conversion */
                chanel_colormanage_cb = channel_colormanage_noop;
        }
index 4368a428186b0a21a56c0e436a2df9de9769b3da..8e5cf80e013635d8ec5c43613df8cb8506cc94c0 100644 (file)
@@ -822,7 +822,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
                                /* convert from float source */
                                float rgb[4];
                                
-                               if (ibuf->float_colorspace) {
+                               if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
                                        /* float buffer was managed already, no need in color space conversion */
                                        copy_v3_v3(rgb, &fromf[from_i]);
                                }