Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-26 16:04:44 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-26 16:06:49 +0300
commit6d22633a96a4ef18051ba6a937ed9c1d1e5d967c (patch)
tree47932a6db0f16f3bf6c59420b251b9c50c3ac82e /source/blender/blenkernel/intern/image.c
parent4f386999ea92ad0f22bffa151581cf5c615c660b (diff)
Fix T66137: added normal map for painting has wrong color space until refresh
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 5c23987a8d9..073b2453299 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -679,41 +679,48 @@ Image *BKE_image_add_generated(Main *bmain,
int floatbuf,
short gen_type,
const float color[4],
- const bool stereo3d)
+ const bool stereo3d,
+ const bool is_data)
{
/* on save, type is changed to FILE in editsima.c */
Image *ima = image_alloc(bmain, name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
+ if (ima == NULL) {
+ return NULL;
+ }
- if (ima) {
- int view_id;
- const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+ int view_id;
+ const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- /* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
- ima->gen_x = width;
- ima->gen_y = height;
- ima->gen_type = gen_type;
- ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
- ima->gen_depth = depth;
- copy_v4_v4(ima->gen_color, color);
-
- for (view_id = 0; view_id < 2; view_id++) {
- ImBuf *ibuf;
- ibuf = add_ibuf_size(
- width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
- image_assign_ibuf(ima, ibuf, stereo3d ? view_id : IMA_NO_INDEX, 0);
-
- /* image_assign_ibuf puts buffer to the cache, which increments user counter. */
- IMB_freeImBuf(ibuf);
- if (!stereo3d) {
- break;
- }
+ /* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
+ ima->gen_x = width;
+ ima->gen_y = height;
+ ima->gen_type = gen_type;
+ ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
+ ima->gen_depth = depth;
+ copy_v4_v4(ima->gen_color, color);
- image_add_view(ima, names[view_id], "");
+ if (is_data) {
+ STRNCPY(ima->colorspace_settings.name,
+ IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DATA));
+ }
+
+ for (view_id = 0; view_id < 2; view_id++) {
+ ImBuf *ibuf;
+ ibuf = add_ibuf_size(
+ width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
+ image_assign_ibuf(ima, ibuf, stereo3d ? view_id : IMA_NO_INDEX, 0);
+
+ /* image_assign_ibuf puts buffer to the cache, which increments user counter. */
+ IMB_freeImBuf(ibuf);
+ if (!stereo3d) {
+ break;
}
- ima->ok = IMA_OK_LOADED;
+ image_add_view(ima, names[view_id], "");
}
+ ima->ok = IMA_OK_LOADED;
+
return ima;
}