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:
authorMatt Ebb <matt@mke3.net>2010-05-18 11:28:44 +0400
committerMatt Ebb <matt@mke3.net>2010-05-18 11:28:44 +0400
commite3587f9e9fb245b168feb7d20ec367486201fd8f (patch)
tree9df1d2d837cf4538a8fc9f573f1d1ec7a8bee7ff /source/blender/imbuf/intern/jp2.c
parentcf4f5c44978246feb17247d512d52bf12b5a0cfe (diff)
Fix [#22304] Tiff 16bit gives darker images
Also fixed similar issue for jpeg2000
Diffstat (limited to 'source/blender/imbuf/intern/jp2.c')
-rw-r--r--source/blender/imbuf/intern/jp2.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 9d045aff3bf..a76c6e780ca 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -24,6 +24,7 @@
#ifdef WITH_OPENJPEG
#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "imbuf.h"
@@ -532,16 +533,23 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
if (rect_float) {
+ float rgb[3];
+
switch (prec) {
case 8: /* Convert blenders float color channels to 8,12 or 16bit ints */
for(y=h-1; y>=0; y--) {
y_row = y*w;
for(x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
+
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ linearrgb_to_srgb_v3_v3(rgb, rect_float);
+ else
+ copy_v3_v3(rgb, rect_float);
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
}
@@ -553,10 +561,15 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
y_row = y*w;
for(x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
+
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ linearrgb_to_srgb_v3_v3(rgb, rect_float);
+ else
+ copy_v3_v3(rgb, rect_float);
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
}
@@ -567,10 +580,15 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
y_row = y*w;
for(x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
+
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ linearrgb_to_srgb_v3_v3(rgb, rect_float);
+ else
+ copy_v3_v3(rgb, rect_float);
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
}