diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-03 10:59:06 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-03 10:59:06 +0300 |
commit | 2bfa061a15762e93f0391e3348f58bcfa512d8fc (patch) | |
tree | b3d51e85572e3272c1e0a4c1817d011f61f81386 /source/blender/imbuf | |
parent | 21369429168c5799125a63ef728947f4fd6668e9 (diff) | |
parent | 2b3ff61d805ccbb219e773e1a5c69e02b0c90109 (diff) |
Merge branch 'master' into blender2.8
Notes:
- Changes in paint_vertex.c were simple to merge, mainly related on passing
evaluation context.
- Conflicts in EditDM and drawmesh.c are solved using code from blender2.8
branch. Those areas are deprecated and not to be used in final release.
However, it's possible that some reference code from master is lost, so
keep attention when adding alpha support for vertex painting.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 8e5cf80e013..98aa7c5353b 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -813,26 +813,51 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) } /* copy pixel data. While copying, we flip the image vertically. */ + const int channels_in_float = ibuf->channels ? ibuf->channels : 4; for (x = 0; x < ibuf->x; x++) { for (y = 0; y < ibuf->y; y++) { - from_i = 4 * (y * ibuf->x + x); + from_i = ((size_t)channels_in_float) * (y * ibuf->x + x); to_i = samplesperpixel * ((ibuf->y - y - 1) * ibuf->x + x); if (pixels16) { /* convert from float source */ float rgb[4]; - - if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) { - /* float buffer was managed already, no need in color space conversion */ - copy_v3_v3(rgb, &fromf[from_i]); + + if (channels_in_float == 3 || channels_in_float == 4) { + if (ibuf->float_colorspace || + (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) + { + /* Float buffer was managed already, no need in color + * space conversion. + */ + copy_v3_v3(rgb, &fromf[from_i]); + } + else { + /* Standard linear-to-srgb conversion if float buffer + * wasn't managed. + */ + linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); + } + if (channels_in_float == 4) { + rgb[3] = fromf[from_i + 3]; + } + else { + rgb[3] = 1.0f; + } } else { - /* standard linear-to-srgb conversion if float buffer wasn't managed */ - linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); + if (ibuf->float_colorspace || + (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) + { + rgb[0] = fromf[from_i]; + } + else { + rgb[0] = linearrgb_to_srgb(fromf[from_i]); + } + rgb[1] = rgb[2] = rgb[0]; + rgb[3] = 1.0f; } - rgb[3] = fromf[from_i + 3]; - for (i = 0; i < samplesperpixel; i++, to_i++) to16[to_i] = FTOUSHORT(rgb[i]); } |