[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47892] trunk/blender/source/blender/imbuf /intern/openexr/openexr_api.cpp: fix for years old bug - OpenEXR always adding alpha channel on load ( how did nobody notice this?).
Campbell Barton
ideasman42 at gmail.com
Thu Jun 14 14:05:43 CEST 2012
Revision: 47892
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47892
Author: campbellbarton
Date: 2012-06-14 12:05:38 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
fix for years old bug - OpenEXR always adding alpha channel on load (how did nobody notice this?).
Modified Paths:
--------------
trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
Modified: trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
--- trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp 2012-06-14 11:47:22 UTC (rev 47891)
+++ trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp 2012-06-14 12:05:38 UTC (rev 47892)
@@ -945,13 +945,16 @@
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 @@
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 @@
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 @@
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 @@
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;
More information about the Bf-blender-cvs
mailing list