summaryrefslogtreecommitdiff
path: root/source/fitz/colorspace.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-10-16 14:51:21 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-10-25 15:50:27 +0200
commitfca9fce5f56dcf45bb69fa0df4bb1c5a2954ffe7 (patch)
treeaebc63c7a3ac865db2fd2afae3d13c9f1d901d6e /source/fitz/colorspace.c
parente815e64406e574a75a33e057f954422d56ade314 (diff)
downloadmupdf-fca9fce5f56dcf45bb69fa0df4bb1c5a2954ffe7.tar.xz
Make alpha channel unmultiply and premultiply utility functions public.
Diffstat (limited to 'source/fitz/colorspace.c')
-rw-r--r--source/fitz/colorspace.c35
1 files changed, 35 insertions, 0 deletions
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