diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-07-12 09:02:47 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-07-12 09:02:47 +0400 |
commit | 8398730043faeb9af860ca7a408a5a4ba49b46f1 (patch) | |
tree | bc38242ec4333e81f5aea3205fffa21f669abffe /source/blender/imbuf | |
parent | d124d3c5cdfdc9d470a4734281396b97c4d3afb5 (diff) |
soc-2008-mxcurioni: merge with trunk - rev 15540
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index b59908fef39..fe352610a40 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -842,7 +842,7 @@ typedef struct RGBA } RGBA; -#if 0 +/* debug only */ static void exr_print_filecontents(InputFile *file) { const ChannelList &channels = file->header().channels(); @@ -853,7 +853,27 @@ static void exr_print_filecontents(InputFile *file) printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type); } } -#endif + +/* for non-multilayer, map R G B A channel names to something that's in this file */ +static const char *exr_rgba_channelname(InputFile *file, const char *chan) +{ + const ChannelList &channels = file->header().channels(); + + for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) + { + const Channel &channel = i.channel(); + const char *str= i.name(); + int len= strlen(str); + if(len) { + if(BLI_strcasecmp(chan, str+len-1)==0) { + return str; + } + } + } + return chan; +} + + static int exr_has_zbuffer(InputFile *file) { @@ -896,7 +916,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags) //printf("OpenEXR-load: image data window %d %d %d %d\n", // dw.min.x, dw.min.y, dw.max.x, dw.max.y); - // exr_print_filecontents(file); + if(0) // debug + exr_print_filecontents(file); is_multi= exr_is_renderresult(file); @@ -935,11 +956,15 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags) /* but, since we read y-flipped (negative y stride) we move to last scanline */ first+= 4*(height-1)*width; - frameBuffer.insert ("R", Slice (FLOAT, (char *) first, xstride, ystride)); - frameBuffer.insert ("G", Slice (FLOAT, (char *) (first+1), xstride, ystride)); - frameBuffer.insert ("B", Slice (FLOAT, (char *) (first+2), xstride, ystride)); - /* 1.0 is fill value */ - frameBuffer.insert ("A", Slice (FLOAT, (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); + frameBuffer.insert ( exr_rgba_channelname(file, "R"), + Slice (FLOAT, (char *) first, xstride, ystride)); + frameBuffer.insert ( exr_rgba_channelname(file, "G"), + Slice (FLOAT, (char *) (first+1), xstride, ystride)); + frameBuffer.insert ( exr_rgba_channelname(file, "B"), + Slice (FLOAT, (char *) (first+2), xstride, ystride)); + + frameBuffer.insert ( exr_rgba_channelname(file, "A"), + Slice (FLOAT, (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */ if(exr_has_zbuffer(file)) { |