Exemplo n.º 1
0
static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
                                         char colorspace[IM_MAX_SPACE])
{
	ImBuf *ibuf;
	LogImageFile *image;
	int width, height, depth;

	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);

	logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);

	image = logImageOpenFromMemory(mem, size);

	if (image == 0) {
		printf("DPX/Cineon: error opening image.\n");
		return 0;
	}

	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) {
		logImageClose(image);
		return 0;
	}

	if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) {
		/* Conversion not possible (probably because the format is unsupported) */
		logImageClose(image);
		MEM_freeN(ibuf);
		return 0;
	}

	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;
}
Exemplo n.º 2
0
static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
                                         char colorspace[IM_MAX_SPACE])
{
	ImBuf *ibuf;
	LogImageFile *image;
	int width, height, depth;

	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);

	logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);

	image = logImageOpenFromMemory(mem, size);

	if (image == NULL) {
		printf("DPX/Cineon: error opening image.\n");
		return NULL;
	}

	logImageGetSize(image, &width, &height, &depth);

	ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
	if (ibuf == NULL) {
		logImageClose(image);
		return NULL;
	}

	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;

	if (flags & IB_alphamode_detect)
		ibuf->flags |= IB_alphamode_premul;

	return ibuf;
}