Color Management: improve compatibility with old files with disabled color management

Still not perfect compatibility, but making it better is a bit tricky now.
This commit is contained in:
Sergey Sharybin
2012-09-11 16:28:01 +00:00
parent 5f512bec47
commit 445020a153
2 changed files with 23 additions and 2 deletions

View File

@@ -7927,20 +7927,40 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
{
Scene *scene;
Image *ima;
int colormanagement_disabled = FALSE;
/* make scenes which are not using color management have got None as display device,
* so they wouldn't perform linear-to-sRGB conversion on display
*/
for (scene = main->scene.first; scene; scene = scene->id.next) {
if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
ColorManagedDisplaySettings *display_settings = &scene->display_settings;
if (display_settings->display_device[0] == 0) {
BKE_scene_disable_color_management(scene);
}
colormanagement_disabled = TRUE;
}
}
for (ima = main->image.first; ima; ima = ima->id.next) {
if (ima->source == IMA_SRC_VIEWER)
if (ima->source == IMA_SRC_VIEWER) {
ima->flag |= IMA_VIEW_AS_RENDER;
}
else if (colormanagement_disabled) {
/* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion
* would happen on display and render
* there's no clear way to check whether color management is enabled or not in render engine
* so set all images to raw if there's at least one scene with color management disabled
* this would still behave incorrect in cases when color management was used for only some
* of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility
* in that cases
*/
BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
}
}
}

View File

@@ -33,6 +33,7 @@ extern "C" {
#include "RE_render_ext.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"
}
BaseImageOperation::BaseImageOperation() : NodeOperation()
@@ -70,7 +71,7 @@ ImBuf *BaseImageOperation::getImBuf()
}
if (ibuf->rect_float == NULL) {
IMB_float_from_rect(ibuf);
IMB_colormanagement_imbuf_float_from_rect(ibuf);
}
return ibuf;
}