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:
authorCampbell Barton <ideasman42@gmail.com>2010-07-12 15:28:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-12 15:28:16 +0400
commit51d8c5d93fa09e7692d1e50434ca3cf4689a8b37 (patch)
tree69642a0ab303af46ea2821c4e6e43556358d188d /source/blender/imbuf
parent41a66025478aab8811eb47f6d1f16ede11de9349 (diff)
[#22824] OpenEXR Save from byte buffer bug
- Saving a typical byte buffer as an exr wasnt converting into linear colorspace. - Remove checks for 1 and 2 channel images, these will write as RGB anyway and are very rare. - 3 Channel images were having the alpha channel written from the red color channel, write 1.0 instead.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index fd505115994..0bac4935d86 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -46,6 +46,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_math_color.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -236,27 +237,44 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
for (int j = ibuf->x; j > 0; j--)
{
to->r = from[0];
- to->g = (channels >= 2)? from[1]: from[0];
- to->b = (channels >= 3)? from[2]: from[0];
- to->a = (channels >= 4)? from[3]: from[0];
+ to->g = from[1];
+ to->b = from[2];
+ to->a = (channels >= 4)? from[3]: 1.0f;
to++; from += 4;
}
}
}
else {
unsigned char *from;
-
- for (int i = ibuf->y-1; i >= 0; i--)
- {
- from= (unsigned char *)ibuf->rect + channels*i*width;
-
- for (int j = ibuf->x; j > 0; j--)
+
+ if(ibuf->profile != IB_PROFILE_NONE) {
+ for (int i = ibuf->y-1; i >= 0; i--)
{
- to->r = (float)(from[0])/255.0;
- to->g = (float)((channels >= 2)? from[1]: from[0])/255.0;
- to->b = (float)((channels >= 3)? from[2]: from[0])/255.0;
- to->a = (float)((channels >= 4)? from[3]: from[0])/255.0;
- to++; from += 4;
+ from= (unsigned char *)ibuf->rect + channels*i*width;
+
+ for (int j = ibuf->x; j > 0; j--)
+ {
+ to->r = (float)(from[0])/255.0;
+ to->g = (float)(from[1])/255.0;
+ to->b = (float)(from[2])/255.0;
+ to->a = (float)(channels >= 4) ? from[3]/255.0 : 1.0f;
+ to++; from += 4;
+ }
+ }
+ }
+ else {
+ for (int i = ibuf->y-1; i >= 0; i--)
+ {
+ from= (unsigned char *)ibuf->rect + channels*i*width;
+
+ for (int j = ibuf->x; j > 0; j--)
+ {
+ to->r = srgb_to_linearrgb((float)from[0] / 255.0);
+ to->g = srgb_to_linearrgb((float)from[1] / 255.0);
+ to->b = srgb_to_linearrgb((float)from[2] / 255.0);
+ to->a = channels >= 4 ? (float)from[3]/255.0 : 1.0f;
+ to++; from += 4;
+ }
}
}
}
@@ -308,9 +326,9 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags)
float *rect[4] = {NULL, NULL, NULL, NULL};
rect[0]= ibuf->rect_float + channels*(height-1)*width;
- rect[1]= (channels >= 2)? rect[0]+1: rect[0];
- rect[2]= (channels >= 3)? rect[0]+2: rect[0];
- rect[3]= (channels >= 4)? rect[0]+3: rect[0];
+ rect[1]= rect[0]+1;
+ rect[2]= rect[0]+2;
+ rect[3]= (channels >= 4)? rect[0]+3: 1.0f;
frameBuffer.insert ("R", Slice (FLOAT, (char *)rect[0], xstride, ystride));
frameBuffer.insert ("G", Slice (FLOAT, (char *)rect[1], xstride, ystride));