summaryrefslogtreecommitdiff
path: root/platform/java/src/com/artifex/mupdf/fitz/ColorParams.java
blob: 0a10e753af98c0354284196345da86db0ce40b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.artifex.mupdf.fitz;

public final class ColorParams
{
	public enum RenderingIntent {
		PERCEPTUAL,
		RELATIVE_COLORIMETRIC,
		SATURATION,
		ABSOLUTE_COLORIMETRIC
	}
	public static final int BP = 32;
	public static final int OP = 64;
	public static final int OPM = 128;

	public static RenderingIntent RI(int flags) {
		switch (flags & 3) {
			default:
			case 0: return RenderingIntent.PERCEPTUAL;
			case 1: return RenderingIntent.RELATIVE_COLORIMETRIC;
			case 2: return RenderingIntent.SATURATION;
			case 3: return RenderingIntent.ABSOLUTE_COLORIMETRIC;
		}
	}

	public static boolean BP(int flags) {
		return (flags & BP) != 0;
	}

	public static boolean OP(int flags) {
		return (flags & OP) != 0;
	}

	public static boolean OPM(int flags) {
		return (flags & OPM) != 0;
	}

	public static int pack(RenderingIntent ri, boolean bp, boolean op, boolean opm) {
		int flags;
		switch (ri) {
		default:
		case PERCEPTUAL: flags = 0; break;
		case RELATIVE_COLORIMETRIC: flags = 1; break;
		case SATURATION: flags = 2; break;
		case ABSOLUTE_COLORIMETRIC: flags = 3; break;
		}
		if (bp) flags |= BP;
		if (op) flags |= OP;
		if (opm) flags |= OPM;
		return flags;
	}
}