Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/oiio/openimageio_api.cpp
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | for (int i = width * height - 1; i >= 0; i--) { | ||||
| pixels[i * 4 + 2] = pixels[i]; | pixels[i * 4 + 2] = pixels[i]; | ||||
| pixels[i * 4 + 1] = pixels[i]; | pixels[i * 4 + 1] = pixels[i]; | ||||
| pixels[i * 4 + 0] = pixels[i]; | pixels[i * 4 + 0] = pixels[i]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static ImBuf *imb_oiio_load_image( | static ImBuf *imb_oiio_load_image( | ||||
| ImageInput *in, int width, int height, int components, int flags, bool is_alpha) | ImageInput *in, int width, int height, int components, eImBufFlags flags, bool is_alpha) | ||||
| { | { | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| int scanlinesize = width * components * sizeof(uchar); | int scanlinesize = width * components * sizeof(uchar); | ||||
| /* allocate the memory for the image */ | /* allocate the memory for the image */ | ||||
| ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, flags | IB_rect); | ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, flags | IB_rect); | ||||
| try { | try { | ||||
| Show All 23 Lines | static ImBuf *imb_oiio_load_image( | ||||
| /* ImBuf always needs 4 channels */ | /* ImBuf always needs 4 channels */ | ||||
| fill_all_channels((uchar *)ibuf->rect, width, height, components, 0xFF); | fill_all_channels((uchar *)ibuf->rect, width, height, components, 0xFF); | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| static ImBuf *imb_oiio_load_image_float( | static ImBuf *imb_oiio_load_image_float( | ||||
| ImageInput *in, int width, int height, int components, int flags, bool is_alpha) | ImageInput *in, int width, int height, int components, eImBufFlags flags, bool is_alpha) | ||||
| { | { | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| int scanlinesize = width * components * sizeof(float); | int scanlinesize = width * components * sizeof(float); | ||||
| /* allocate the memory for the image */ | /* allocate the memory for the image */ | ||||
| ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, flags | IB_rectfloat); | ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, flags | IB_rectfloat); | ||||
| try { | try { | ||||
| Show All 38 Lines | const char *photoshop_extension[] = { | ||||
| ".pdd", | ".pdd", | ||||
| ".psb", | ".psb", | ||||
| NULL, | NULL, | ||||
| }; | }; | ||||
| return BLI_path_extension_check_array(filename, photoshop_extension); | return BLI_path_extension_check_array(filename, photoshop_extension); | ||||
| } | } | ||||
| int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags) | int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, eImBufFlags flags) | ||||
| { | { | ||||
| if (flags & IB_mem) { | if (flags & IB_mem) { | ||||
| std::cerr << __func__ << ": Photoshop PSD-save: Create PSD in memory" | std::cerr << __func__ << ": Photoshop PSD-save: Create PSD in memory" | ||||
| << " currently not supported" << std::endl; | << " currently not supported" << std::endl; | ||||
| imb_addencodedbufferImBuf(ibuf); | imb_addencodedbufferImBuf(ibuf); | ||||
| ibuf->encodedsize = 0; | ibuf->encodedsize = 0; | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE]) | struct ImBuf *imb_load_photoshop(const char *filename, | ||||
| eImBufFlags flags, | |||||
| char colorspace[IM_MAX_SPACE]) | |||||
| { | { | ||||
| struct ImBuf *ibuf = NULL; | struct ImBuf *ibuf = NULL; | ||||
| int width, height, components; | int width, height, components; | ||||
| bool is_float, is_alpha, is_half; | bool is_float, is_alpha, is_half; | ||||
| int basesize; | int basesize; | ||||
| char file_colorspace[IM_MAX_SPACE]; | char file_colorspace[IM_MAX_SPACE]; | ||||
| const bool is_colorspace_manually_set = (colorspace[0] != '\0'); | const bool is_colorspace_manually_set = (colorspace[0] != '\0'); | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | struct ImBuf *imb_load_photoshop(const char *filename, | ||||
| if (!ibuf) { | if (!ibuf) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* ImBuf always needs 4 channels */ | /* ImBuf always needs 4 channels */ | ||||
| ibuf->ftype = IMB_FTYPE_PSD; | ibuf->ftype = IMB_FTYPE_PSD; | ||||
| ibuf->channels = 4; | ibuf->channels = 4; | ||||
| ibuf->planes = (3 + (is_alpha ? 1 : 0)) * 4 << basesize; | ibuf->planes = (3 + (is_alpha ? 1 : 0)) * 4 << basesize; | ||||
| ibuf->flags |= (is_float && is_half) ? IB_halffloat : 0; | ibuf->flags |= (is_float && is_half) ? IB_halffloat : static_cast<eImBufFlags>(0); | ||||
| try { | try { | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| catch (const std::exception &exc) { | catch (const std::exception &exc) { | ||||
| std::cerr << exc.what() << std::endl; | std::cerr << exc.what() << std::endl; | ||||
| if (ibuf) { | if (ibuf) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| Show All 12 Lines | |||||