diff --git a/intern/cycles/scene/colorspace.cpp b/intern/cycles/scene/colorspace.cpp index 189e3bc752d..9d598927864 100644 --- a/intern/cycles/scene/colorspace.cpp +++ b/intern/cycles/scene/colorspace.cpp @@ -95,16 +95,19 @@ bool ColorSpaceManager::colorspace_is_data(ustring colorspace) } ustring ColorSpaceManager::detect_known_colorspace(ustring colorspace, + const char *file_colorspace, const char *file_format, bool is_float) { if (colorspace == u_colorspace_auto) { /* Auto detect sRGB or raw if none specified. */ if (is_float) { - bool srgb = (colorspace == "sRGB" || colorspace == "GammaCorrected" || - (colorspace.empty() && - (strcmp(file_format, "png") == 0 || strcmp(file_format, "tiff") == 0 || - strcmp(file_format, "dpx") == 0 || strcmp(file_format, "jpeg2000") == 0))); + bool srgb = (strcmp(file_colorspace, "sRGB") == 0 || + strcmp(file_colorspace, "GammaCorrected") == 0 || + (file_colorspace[0] == '\0' && + (strcmp(file_format, "png") == 0 || strcmp(file_format, "jpeg") == 0 || + strcmp(file_format, "tiff") == 0 || strcmp(file_format, "dpx") == 0 || + strcmp(file_format, "jpeg2000") == 0))); return srgb ? u_colorspace_srgb : u_colorspace_raw; } else { diff --git a/intern/cycles/scene/colorspace.h b/intern/cycles/scene/colorspace.h index 985fc756763..a458d870bfd 100644 --- a/intern/cycles/scene/colorspace.h +++ b/intern/cycles/scene/colorspace.h @@ -21,6 +21,7 @@ class ColorSpaceManager { * convert to and from. If the colorspace is u_colorspace_auto, we auto * detect a colospace. */ static ustring detect_known_colorspace(ustring colorspace, + const char *file_colorspace, const char *file_format, bool is_float); diff --git a/intern/cycles/scene/image.cpp b/intern/cycles/scene/image.cpp index 0352ed3e66c..a5c794bc762 100644 --- a/intern/cycles/scene/image.cpp +++ b/intern/cycles/scene/image.cpp @@ -261,7 +261,7 @@ void ImageMetaData::detect_colorspace() { /* Convert used specified color spaces to one we know how to handle. */ colorspace = ColorSpaceManager::detect_known_colorspace( - colorspace, colorspace_file_format, is_float()); + colorspace, colorspace_file_hint.c_str(), colorspace_file_format, is_float()); if (colorspace == u_colorspace_raw) { /* Nothing to do. */ diff --git a/intern/cycles/scene/image.h b/intern/cycles/scene/image.h index 9edb6a7eaf5..da47d8144bc 100644 --- a/intern/cycles/scene/image.h +++ b/intern/cycles/scene/image.h @@ -69,6 +69,7 @@ class ImageMetaData { /* Optional color space, defaults to raw. */ ustring colorspace; + string colorspace_file_hint; const char *colorspace_file_format; /* Optional transform for 3D images. */ diff --git a/intern/cycles/scene/image_oiio.cpp b/intern/cycles/scene/image_oiio.cpp index 7bcf1ccb073..5790c179d77 100644 --- a/intern/cycles/scene/image_oiio.cpp +++ b/intern/cycles/scene/image_oiio.cpp @@ -85,6 +85,7 @@ bool OIIOImageLoader::load_metadata(const ImageDeviceFeatures & /*features*/, } metadata.colorspace_file_format = in->format_name(); + metadata.colorspace_file_hint = spec.get_string_attribute("oiio:ColorSpace"); in->close();