diff options
Diffstat (limited to 'source/blender/imbuf/intern/openexr/openexr_api.cpp')
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index da7b31cc2ba..defbfcd3e99 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -85,6 +85,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include <ImfCompression.h> #include <ImfCompressionAttribute.h> #include <ImfStringAttribute.h> +#include <ImfStandardAttributes.h> using namespace Imf; using namespace Imath; @@ -302,6 +303,9 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf) for (info = ibuf->metadata; info; info = info->next) header->insert(info->key, StringAttribute(info->value)); + + if (ibuf->ppm[0] > 0.0f) + addXDensity(*header, ibuf->ppm[0] / 39.3700787f); /* 1 meter = 39.3700787 inches */ } static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags) @@ -882,6 +886,14 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa const char *token; char tokenbuf[EXR_TOT_MAXNAME]; int len; + + /* some multilayers have the combined buffer with names A B G R saved */ + if (name[1] == 0) { + echan->chan_id = name[0]; + layname[0] = '\0'; + strcpy(passname, "Combined"); + return 1; + } /* last token is single character channel identifier */ len = imb_exr_split_token(name, end, &token); @@ -1093,11 +1105,29 @@ static int exr_is_multilayer(InputFile *file) const ChannelList &channels = file->header().channels(); std::set <std::string> layerNames; + /* will not include empty layer names */ channels.layers(layerNames); if (comments || layerNames.size() > 1) return 1; + if (layerNames.size()) { + /* if layerNames is not empty, it means at least one layer is non-empty, + * but it also could be layers without names in the file and such case + * shall be considered a multilayer exr + * + * that's what we do here: test whether there're empty layer names together + * with non-empty ones in the file + */ + for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++) { + std::string layerName = i.name(); + size_t pos = layerName.rfind ('.'); + + if (pos == std::string::npos) + return 1; + } + } + return 0; } @@ -1136,6 +1166,12 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char const int is_alpha = exr_has_alpha(file); ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0); + + if (hasXDensity(file->header())) { + ibuf->ppm[0] = xDensity(file->header()) * 39.3700787f; + ibuf->ppm[1] = ibuf->ppm[0] * file->header().pixelAspectRatio(); + } + ibuf->ftype = OPENEXR; if (!(flags & IB_test)) { @@ -1197,6 +1233,9 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char delete file; } } + + if (flags & IB_alphamode_detect) + ibuf->flags |= IB_alphamode_premul; } return(ibuf); } |