Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/oiio/openimageio_api.cpp
| Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags) | ||||
| 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, int 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; | 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'); | ||||
| /* load image from file through OIIO */ | /* load image from file through OIIO */ | ||||
| if (imb_is_a_photoshop(filename) == 0) { | if (imb_is_a_photoshop(filename) == 0) { | ||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| Show All 32 Lines | struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE]) | ||||
| } | } | ||||
| width = spec.width; | width = spec.width; | ||||
| height = spec.height; | height = spec.height; | ||||
| components = spec.nchannels; | components = spec.nchannels; | ||||
| is_alpha = spec.alpha_channel != -1; | is_alpha = spec.alpha_channel != -1; | ||||
| basesize = spec.format.basesize(); | basesize = spec.format.basesize(); | ||||
| is_float = basesize > 1; | is_float = basesize > 1; | ||||
| is_half = spec.format == TypeDesc::HALF; | |||||
| /* we only handle certain number of components */ | /* we only handle certain number of components */ | ||||
| if (!(components >= 1 && components <= 4)) { | if (!(components >= 1 && components <= 4)) { | ||||
| if (in) { | if (in) { | ||||
| in->close(); | in->close(); | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Show All 12 Lines | struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE]) | ||||
| 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; | |||||
| 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 | |||||