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
This commit is contained in:
Sergey Sharybin
2018-12-11 12:17:26 +01:00
parent 84b02dc54a
commit 66d8bfb85c
7 changed files with 47 additions and 27 deletions

View File

@@ -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)