Beispiel #1
0
ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
{
	ImBuf *ibuf;
	ImFileType *type;
	char effective_colorspace[IM_MAX_SPACE] = "";

	if (mem == NULL) {
		fprintf(stderr, "%s: NULL pointer\n", __func__);
		return NULL;
	}

	if (colorspace)
		BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace));

	for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
		if (type->load) {
			ibuf = type->load(mem, size, flags, effective_colorspace);
			if (ibuf) {
				imb_handle_alpha(ibuf, flags, colorspace, effective_colorspace);
				return ibuf;
			}
		}
	}

	if ((flags & IB_test) == 0)
		fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);

	return NULL;
}
Beispiel #2
0
ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags)
{
	ImBuf *ibuf;
	ImFileType *type;

	if(mem == NULL) {
		printf("Error in ibImageFromMemory: NULL pointer\n");
		return NULL;
	}

	for(type=IMB_FILE_TYPES; type->is_a; type++) {
		if(type->load) {
			ibuf= type->load(mem, size, flags);
			if(ibuf) {
				if(flags & IB_premul) {
					IMB_premultiply_alpha(ibuf);
					ibuf->flags |= IB_premul;
				}

				return ibuf;
			}
		}
	}

	fprintf(stderr, "Unknown fileformat\n");
	
	return NULL;
}