diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-12-11 14:17:26 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-12-11 17:50:02 +0300 |
commit | 66d8bfb85c61aafe3bad2edf0e7b4d9d694ee2e7 (patch) | |
tree | 97653b0aa4c87ca5349284405f12323d3c59c04e /source/blender/imbuf/intern/oiio/openimageio_api.cpp | |
parent | 84b02dc54a8c06e963a263e7232e41a993ab21c8 (diff) |
Update code to be compatible with OIIO 2.0
There are some changes in API of OpenImageIO, but those are quite
simple to keep working with older and newer library versions.
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D4064
Diffstat (limited to 'source/blender/imbuf/intern/oiio/openimageio_api.cpp')
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index f018bfc09d7..34d5cccac84 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -35,6 +35,11 @@ #include "utfconv.h" #endif +// NOTE: Keep first, BLI_path_util conflicts with OIIO's format. +#include <memory> +#include <openimageio_api.h> +#include <OpenImageIO/imageio.h> + extern "C" { #include "MEM_guardedalloc.h" @@ -48,12 +53,10 @@ extern "C" #include "IMB_colormanagement_intern.h" } -#include <openimageio_api.h> -#include <OpenImageIO/imageio.h> - OIIO_NAMESPACE_USING using std::string; +using std::unique_ptr; typedef unsigned char uchar; @@ -197,7 +200,6 @@ int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags) struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE]) { - ImageInput *in = NULL; struct ImBuf *ibuf = NULL; int width, height, components; bool is_float, is_alpha; @@ -210,7 +212,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); - in = ImageInput::create(filename); + unique_ptr<ImageInput> in(ImageInput::create(filename)); if (!in) { std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl << OIIO_NAMESPACE::geterror() << std::endl; @@ -223,7 +225,6 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac if (!in->open(filename, spec, config)) { std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl << in->geterror() << std::endl; - delete in; return NULL; } @@ -249,19 +250,17 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac if (!(components >= 1 && components <= 4)) { if (in) { in->close(); - delete in; } return NULL; } if (is_float) - ibuf = imb_oiio_load_image_float(in, width, height, components, flags, is_alpha); + ibuf = imb_oiio_load_image_float(in.get(), width, height, components, flags, is_alpha); else - ibuf = imb_oiio_load_image(in, width, height, components, flags, is_alpha); + ibuf = imb_oiio_load_image(in.get(), width, height, components, flags, is_alpha); if (in) { in->close(); - delete in; } if (!ibuf) |