All pastes #2061912 Raw Edit

Unnamed

public text v1 · immutable
#2061912 ·published 2011-05-17 03:10 UTC
rendered paste body
#ifdef __cplusplus
extern "C"
{
#endif

#include "imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
//#include "IMB_allocimbuf.h"
//#include "oiio_to_imbuf.h"

#ifdef __cplusplus
}
#endif

#include <OpenImageIO/imageio.h>

#include "oiio_to_imbuf.h"

//using namespace OpenImageIO;
//OIIO_NAMESPACE_USING
//#ifdef __cplusplus
//extern "C"
//{
//#endif

ImBuf* oiio_to_imbuf(const char* filename)
{

        //ImBuf ibuf;
        ImBuf* ibuf = NULL;
        OpenImageIO::ImageInput *in = OpenImageIO::ImageInput::create (filename);
        OpenImageIO::ImageSpec spec;
        in->open (filename, spec);
        
        ibuf = IMB_allocImBuf(spec.width, spec.height, 8 * spec.pixel_bytes(), 0);
        imb_addrectfloatImBuf(ibuf);
        
        ibuf->x = spec.width;
        ibuf->y = spec.height;
        ibuf->channels = spec.nchannels;
        in->read_image (OpenImageIO::TypeDesc::FLOAT, ibuf->rect_float);
        in->close ();
        delete in;
        return ibuf;

}

//#ifdef __cplusplus
//}
//#endif