From fca9fce5f56dcf45bb69fa0df4bb1c5a2954ffe7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 16 Oct 2018 14:51:21 +0200 Subject: Make alpha channel unmultiply and premultiply utility functions public. --- source/fitz/colorspace.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'source/fitz/colorspace.c') diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index 4a957d20..89e6b9be 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -145,6 +145,41 @@ void fz_cmm_fin_profile(fz_context *ctx, fz_iccprofile *profile) ctx->colorspace->cmm->fin_profile(ctx->cmm_instance, profile); } +void fz_premultiply_row(fz_context *ctx, int n, int c, int w, unsigned char *s) +{ + unsigned char a; + int k; + int n1 = n-1; + + for (; w > 0; w--) + { + a = s[n1]; + for (k = 0; k < c; k++) + s[k] = fz_mul255(s[k], a); + s += n; + } +} + +void fz_unmultiply_row(fz_context *ctx, int n, int c, int w, unsigned char *s, const unsigned char *in) +{ + int a, inva; + int k; + int n1 = n-1; + + for (; w > 0; w--) + { + a = in[n1]; + inva = a ? 255 * 256 / a : 0; + for (k = 0; k < c; k++) + s[k] = (in[k] * inva) >> 8; + for (;k < n1; k++) + s[k] = in[k]; + s[n1] = a; + s += n; + in += n; + } +} + #define SLOWCMYK #if FZ_ENABLE_ICC -- cgit v1.2.3