diff options
Diffstat (limited to 'source/blender/imbuf/intern/cineon/cineon_dpx.c')
-rw-r--r-- | source/blender/imbuf/intern/cineon/cineon_dpx.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index c8bc3f8ebb8..255af7dc039 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -63,37 +63,33 @@ static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int us image = logImageOpenFromMemory(mem, size); - if (image == 0) { + if (image == NULL) { printf("DPX/Cineon: error opening image.\n"); - return 0; + return NULL; } logImageGetSize(image, &width, &height, &depth); - if (width == 0 || height == 0) { - logImageClose(image); - return 0; - } - ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags); - if (ibuf == 0) { + if (ibuf == NULL) { logImageClose(image); - return 0; + return NULL; } - if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) { - /* Conversion not possible (probably because the format is unsupported) */ - logImageClose(image); - MEM_freeN(ibuf); - return 0; + if (!(flags & IB_test)) { + if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) { + logImageClose(image); + IMB_freeImBuf(ibuf); + return NULL; + } + IMB_flipy(ibuf); } logImageClose(image); ibuf->ftype = use_cineon ? CINEON : DPX; - IMB_flipy(ibuf); - if (flags & IB_rect) - IMB_rect_from_float(ibuf); + if (flags & IB_alphamode_detect) + ibuf->flags |= IB_alphamode_premul; return ibuf; } @@ -131,14 +127,14 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4), (ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender"); - if (logImage == 0) { + if (logImage == NULL) { printf("DPX/Cineon: error creating file.\n"); return 0; } - if (ibuf->rect_float != 0 && bitspersample != 8) { + if (ibuf->rect_float != NULL && bitspersample != 8) { /* don't use the float buffer to save 8 bpp picture to prevent color banding - (there's no dithering algorithm behing the logImageSetDataRGBA function) */ + * (there's no dithering algorithm behing the logImageSetDataRGBA function) */ fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon"); @@ -154,11 +150,11 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon MEM_freeN(fbuf); } else { - if (ibuf->rect == 0) + if (ibuf->rect == NULL) IMB_rect_from_float(ibuf); fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon"); - if (fbuf == 0) { + if (fbuf == NULL) { printf("DPX/Cineon: error allocating memory.\n"); logImageClose(logImage); return 0; @@ -195,7 +191,7 @@ ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspa { if (imb_is_cineon(mem)) return imb_load_dpx_cineon(mem, size, 1, flags, colorspace); - return 0; + return NULL; } int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) @@ -212,5 +208,5 @@ ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[ { if (imb_is_dpx(mem)) return imb_load_dpx_cineon(mem, size, 0, flags, colorspace); - return 0; + return NULL; } |