コード例 #1
0
void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin)
{
	/* margin */
	IMB_filter_extend(ibuf, mask, margin);

	if (ibuf->planes != R_IMF_PLANES_RGBA)
		/* clear alpha added by filtering */
		IMB_rectfill_alpha(ibuf, 1.0f);
}
コード例 #2
0
static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPACE], char effective_colorspace[IM_MAX_SPACE])
{
	int alpha_flags;

	if (colorspace) {
		if (ibuf->rect) {
			/* byte buffer is never internally converted to some standard space,
			 * store pointer to it's color space descriptor instead
			 */
			ibuf->rect_colorspace = colormanage_colorspace_get_named(effective_colorspace);
		}

		BLI_strncpy(colorspace, effective_colorspace, IM_MAX_SPACE);
	}

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

	if (flags & IB_ignore_alpha) {
		IMB_rectfill_alpha(ibuf, 1.0f);
	}
	else {
		if (alpha_flags & IB_alphamode_premul) {
			if (ibuf->rect) {
				IMB_unpremultiply_alpha(ibuf);
			}
			else {
				/* pass, floats are expected to be premul */
			}
		}
		else {
			if (ibuf->rect_float) {
				IMB_premultiply_alpha(ibuf);
			}
			else {
				/* pass, bytes are expected to be straight */
			}
		}
	}

	/* OCIO_TODO: in some cases it's faster to do threaded conversion,
	 *            but how to distinguish such cases */
	colormanage_imbuf_make_linear(ibuf, effective_colorspace);
}
コード例 #3
0
void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
{
	/* must check before filtering */
	const short is_new_alpha = (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf);

	/* Margin */
	if (filter) {
		IMB_filter_extend(ibuf, mask, filter);
	}

	/* if the bake results in new alpha then change the image setting */
	if (is_new_alpha) {
		ibuf->planes = R_IMF_PLANES_RGBA;
	}
	else {
		if (filter && ibuf->planes != R_IMF_PLANES_RGBA) {
			/* clear alpha added by filtering */
			IMB_rectfill_alpha(ibuf, 1.0f);
		}
	}
}