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>2012-06-14 16:05:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-14 16:05:38 +0400
commite2cda811ac2b8bd054afe2d7e0a0c760de96080c (patch)
treeb564c52bace5280d874075d146dd2c9f8f818ce2 /source/blender/imbuf/intern/openexr/openexr_api.cpp
parentd3c8cdc1c3fb4f24cfcdbe5f211c505349f76a61 (diff)
fix for years old bug - OpenEXR always adding alpha channel on load (how did nobody notice this?).
Diffstat (limited to 'source/blender/imbuf/intern/openexr/openexr_api.cpp')
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index f2beb045dfa..18957cb8260 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -945,13 +945,16 @@ static const char *exr_rgba_channelname(InputFile *file, const char *chan)
return chan;
}
-
-
static int exr_has_zbuffer(InputFile *file)
{
return !(file->header().channels().findChannel("Z") == NULL);
}
+static int exr_has_alpha(InputFile *file)
+{
+ return !(file->header().channels().findChannel("A") == NULL);
+}
+
static int exr_is_multilayer(InputFile *file)
{
const StringAttribute *comments = file->header().findTypedAttribute<StringAttribute>("BlenderMultiChannel");
@@ -966,7 +969,8 @@ static int exr_is_multilayer(InputFile *file)
return 0;
}
-struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags){
+struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
+{
struct ImBuf *ibuf = NULL;
InputFile *file = NULL;
@@ -979,8 +983,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags){
file = new InputFile(*membuf);
Box2i dw = file->header().dataWindow();
- int width = dw.max.x - dw.min.x + 1;
- int height = dw.max.y - dw.min.y + 1;
+ const int width = dw.max.x - dw.min.x + 1;
+ const int height = dw.max.y - dw.min.y + 1;
//printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
@@ -995,8 +999,9 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags){
printf("Error: can't process EXR multilayer file\n");
}
else {
+ const int is_alpha = exr_has_alpha(file);
- ibuf = IMB_allocImBuf(width, height, 32, 0);
+ ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0);
ibuf->ftype = OPENEXR;
/* openEXR is linear as per EXR spec */
@@ -1031,8 +1036,9 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags){
frameBuffer.insert(exr_rgba_channelname(file, "B"),
Slice(Imf::FLOAT, (char *) (first + 2), xstride, ystride));
+ /* 1.0 is fill value, this still neesd to be assigned even when (is_alpha == 0) */
frameBuffer.insert(exr_rgba_channelname(file, "A"),
- Slice(Imf::FLOAT, (char *) (first + 3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */
+ Slice(Imf::FLOAT, (char *) (first + 3), xstride, ystride, 1, 1, 1.0f));
if (exr_has_zbuffer(file)) {
float *firstz;