diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-15 01:40:29 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-15 01:40:29 +0400 |
commit | b94993941fe5a503627b45fd55f93f3bebbad97d (patch) | |
tree | 0522d704c999b20311e45deaa9574857ae69a0fa /intern/cycles/render/image.cpp | |
parent | 6e03b70def962bf4c7ee346916c7472700c7f336 (diff) |
Fix #34252: cycles rendering 16bit PNG with too light colors.
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r-- | intern/cycles/render/image.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 6bfaf48c0c9..8e844bc788e 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -85,9 +85,10 @@ bool ImageManager::set_animation_frame_update(int frame) return false; } -bool ImageManager::is_float_image(const string& filename, void *builtin_data) +bool ImageManager::is_float_image(const string& filename, void *builtin_data, bool& is_linear) { bool is_float = false; + is_linear = false; if(builtin_data) { if(builtin_image_info_cb) { @@ -95,6 +96,9 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) builtin_image_info_cb(filename, builtin_data, is_float, width, height, channels); } + if(is_float) + is_linear = true; + return is_float; } @@ -106,13 +110,29 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) if(in->open(filename, spec)) { /* check the main format, and channel formats; * if any take up more than one byte, we'll need a float texture slot */ - if(spec.format.basesize() > 1) + if(spec.format.basesize() > 1) { is_float = true; + is_linear = true; + } for(size_t channel = 0; channel < spec.channelformats.size(); channel++) { - if(spec.channelformats[channel].basesize() > 1) + if(spec.channelformats[channel].basesize() > 1) { is_float = true; + is_linear = true; + } + } + + /* basic color space detection, not great but better than nothing + * before we do OpenColorIO integration */ + if(is_float) { + string colorspace = spec.get_string_attribute("oiio:ColorSpace"); + + is_linear = !(colorspace == "sRGB" || + colorspace == "GammaCorrected" || + strcmp(in->format_name(), "png") == 0); } + else + is_linear = false; in->close(); } @@ -123,13 +143,13 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) return is_float; } -int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float) +int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear) { Image *img; size_t slot; /* load image info and find out if we need a float texture */ - is_float = (pack_images)? false: is_float_image(filename, builtin_data); + is_float = (pack_images)? false: is_float_image(filename, builtin_data, is_linear); if(is_float) { /* find existing image */ |