diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-23 18:41:03 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-23 18:41:03 +0400 |
commit | a1e24889ba384cfde52921df7aab54b01f868ce6 (patch) | |
tree | 7062be386ddba11fa209c436d8e3053b6d9a7299 /source/blender/blenkernel/intern/image.c | |
parent | 2637efa2a372425d12c7c93b66ba87483a71f3b1 (diff) |
A bit alternative fix for bug mentioned in rev50826
We need to assign color space for generated images when it's empty.
Do this in add_ibuf_size function in cases image's color space is
empty.
So now color management is always called with correct color space.
P.S. At least it should. If there're more similar issues please
let me know :)
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0e4d8a89386..d620fc50e86 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -604,7 +604,7 @@ Image *BKE_image_load_exists(const char *filepath) } static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, - float color[4], const char *colorspace) + float color[4], ColorManagedColorspaceSettings *colorspace_settings) { ImBuf *ibuf; unsigned char *rect = NULL; @@ -613,13 +613,24 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char if (floatbuf) { ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float = ibuf->rect_float; + + if (colorspace_settings->name[0] == '\0') { + const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT); + + BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name)); + } } else { ibuf = IMB_allocImBuf(width, height, depth, IB_rect); rect = (unsigned char *)ibuf->rect; - if (colorspace) - IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace); + if (colorspace_settings->name[0] == '\0') { + const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE); + + BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name)); + } + + IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name); } BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); @@ -647,7 +658,6 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch if (ima) { ImBuf *ibuf; - const char *colorspace; /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */ ima->gen_x = width; @@ -655,17 +665,9 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch ima->gen_type = gen_type; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, NULL); + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - /* assign colorspaces */ - if (floatbuf) - colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT); - else - colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE); - - BLI_strncpy(ima->colorspace_settings.name, colorspace, sizeof(ima->colorspace_settings.name)); - ima->ok = IMA_OK_LOADED; } @@ -2798,7 +2800,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) if (ima->gen_x == 0) ima->gen_x = 1024; if (ima->gen_y == 0) ima->gen_y = 1024; ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, - color, ima->colorspace_settings.name); + color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok = IMA_OK_LOADED; } |