diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-14 16:05:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-14 16:05:38 +0400 |
commit | e2cda811ac2b8bd054afe2d7e0a0c760de96080c (patch) | |
tree | b564c52bace5280d874075d146dd2c9f8f818ce2 /source/blender | |
parent | d3c8cdc1c3fb4f24cfcdbe5f211c505349f76a61 (diff) |
fix for years old bug - OpenEXR always adding alpha channel on load (how did nobody notice this?).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 20 |
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; |