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@pandora.be>2012-10-02 00:21:50 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-10-02 00:21:50 +0400
commit4572a82de76668c671c37951fcf1c459b8231a86 (patch)
tree5fdfc7fac40b7b69bfa0ad037a1bc660b378925a
parentb1f1ee5138a1398fb5a824732a9ec9d74b3113e1 (diff)
Fix #32712: non-multilayer openexr file save for a single channel image would
write wrong colors for float and crash for half-float.
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 13078921d1c..066d07a36c5 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -372,10 +372,10 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
for (int j = ibuf->x; j > 0; j--) {
to->r = from[0];
- to->g = from[1];
- to->b = from[2];
+ to->g = (channels >= 2) ? from[1] : from[0];
+ to->b = (channels >= 3) ? from[2] : from[0];
to->a = (channels >= 4) ? from[3] : 1.0f;
- to++; from += 4;
+ to++; from += channels;
}
}
}
@@ -383,7 +383,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
unsigned char *from;
for (int i = ibuf->y - 1; i >= 0; i--) {
- from = (unsigned char *)ibuf->rect + channels * i * width;
+ from = (unsigned char *)ibuf->rect + 4 * i * width;
for (int j = ibuf->x; j > 0; j--) {
to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
@@ -448,8 +448,8 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag
/* last scanline, stride negative */
rect[0] = ibuf->rect_float + channels * (height - 1) * width;
- rect[1] = rect[0] + 1;
- rect[2] = rect[0] + 2;
+ 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]; /* red as alpha, is this needed since alpha isn't written? */
frameBuffer.insert("R", Slice(Imf::FLOAT, (char *)rect[0], xstride, ystride));