Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/openexr/openexr_api.cpp
| Show First 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | static void openexr_header_metadata_callback(void *data, | ||||
| const char *propname, | const char *propname, | ||||
| char *prop, | char *prop, | ||||
| int UNUSED(len)) | int UNUSED(len)) | ||||
| { | { | ||||
| Header *header = (Header *)data; | Header *header = (Header *)data; | ||||
| header->insert(propname, StringAttribute(prop)); | header->insert(propname, StringAttribute(prop)); | ||||
| } | } | ||||
| static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags) | static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const eImBufFlags flags) | ||||
| { | { | ||||
| const int channels = ibuf->channels; | const int channels = ibuf->channels; | ||||
| const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); | const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); | ||||
| const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ | const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ | ||||
| const int width = ibuf->x; | const int width = ibuf->x; | ||||
| const int height = ibuf->y; | const int height = ibuf->y; | ||||
| OStream *file_stream = NULL; | OStream *file_stream = NULL; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | catch (const std::exception &exc) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| delete file_stream; | delete file_stream; | ||||
| return true; | return true; | ||||
| } | } | ||||
| static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flags) | static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const eImBufFlags flags) | ||||
| { | { | ||||
| const int channels = ibuf->channels; | const int channels = ibuf->channels; | ||||
| const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); | const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); | ||||
| const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ | const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ | ||||
| const int width = ibuf->x; | const int width = ibuf->x; | ||||
| const int height = ibuf->y; | const int height = ibuf->y; | ||||
| OStream *file_stream = NULL; | OStream *file_stream = NULL; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | catch (const std::exception &exc) { | ||||
| delete file_stream; | delete file_stream; | ||||
| return false; | return false; | ||||
| } | } | ||||
| delete file_stream; | delete file_stream; | ||||
| return true; | return true; | ||||
| } | } | ||||
| int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags) | int imb_save_openexr(struct ImBuf *ibuf, const char *name, eImBufFlags flags) | ||||
| { | { | ||||
| if (flags & IB_mem) { | if (flags & IB_mem) { | ||||
| imb_addencodedbufferImBuf(ibuf); | imb_addencodedbufferImBuf(ibuf); | ||||
| ibuf->encodedsize = 0; | ibuf->encodedsize = 0; | ||||
| } | } | ||||
| if (ibuf->foptions.flag & OPENEXR_HALF) { | if (ibuf->foptions.flag & OPENEXR_HALF) { | ||||
| return (int)imb_save_openexr_half(ibuf, name, flags); | return (int)imb_save_openexr_half(ibuf, name, flags); | ||||
| ▲ Show 20 Lines • Show All 1,274 Lines • ▼ Show 20 Lines | |||||
| bool IMB_exr_has_multilayer(void *handle) | bool IMB_exr_has_multilayer(void *handle) | ||||
| { | { | ||||
| ExrHandle *data = (ExrHandle *)handle; | ExrHandle *data = (ExrHandle *)handle; | ||||
| return imb_exr_is_multi(*data->ifile); | return imb_exr_is_multi(*data->ifile); | ||||
| } | } | ||||
| struct ImBuf *imb_load_openexr(const unsigned char *mem, | struct ImBuf *imb_load_openexr(const unsigned char *mem, | ||||
| size_t size, | size_t size, | ||||
| int flags, | eImBufFlags flags, | ||||
| char colorspace[IM_MAX_SPACE]) | char colorspace[IM_MAX_SPACE]) | ||||
| { | { | ||||
| struct ImBuf *ibuf = NULL; | struct ImBuf *ibuf = NULL; | ||||
| IMemStream *membuf = NULL; | IMemStream *membuf = NULL; | ||||
| MultiPartInputFile *file = NULL; | MultiPartInputFile *file = NULL; | ||||
| if (imb_is_a_openexr(mem) == 0) { | if (imb_is_a_openexr(mem) == 0) { | ||||
| return (NULL); | return (NULL); | ||||
| Show All 22 Lines | try { | ||||
| /* do not make an ibuf when */ | /* do not make an ibuf when */ | ||||
| if (is_multi && !(flags & IB_test) && !(flags & IB_multilayer)) { | if (is_multi && !(flags & IB_test) && !(flags & IB_multilayer)) { | ||||
| printf("Error: can't process EXR multilayer file\n"); | printf("Error: can't process EXR multilayer file\n"); | ||||
| } | } | ||||
| else { | else { | ||||
| const int is_alpha = exr_has_alpha(*file); | const int is_alpha = exr_has_alpha(*file); | ||||
| ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0); | ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, static_cast<eImBufFlags>(0)); | ||||
| ibuf->flags |= exr_is_half_float(*file) ? IB_halffloat : 0; | if (exr_is_half_float(*file)) { | ||||
| ibuf->flags |= IB_halffloat; | |||||
| } | |||||
| if (hasXDensity(file->header(0))) { | if (hasXDensity(file->header(0))) { | ||||
| ibuf->ppm[0] = xDensity(file->header(0)) * 39.3700787f; | ibuf->ppm[0] = xDensity(file->header(0)) * 39.3700787f; | ||||
| ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio(); | ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio(); | ||||
| } | } | ||||
| ibuf->ftype = IMB_FTYPE_OPENEXR; | ibuf->ftype = IMB_FTYPE_OPENEXR; | ||||
| ▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines | |||||