mupdf
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1// Copyright (C) 2004-2025 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_FITZ_COLOR_H
24#define MUPDF_FITZ_COLOR_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/store.h"
29
30#if FZ_ENABLE_ICC
34typedef struct fz_icc_profile fz_icc_profile;
35#endif
36
41
50typedef struct fz_pixmap fz_pixmap;
51
52/* Color handling parameters: rendering intent, overprint, etc. */
53
54enum
55{
56 /* Same order as needed by lcms */
61};
62
63/* We abuse the top bit of the rendering intent to hold details of
64 * whether we are in a softmask or not. This should not be used by
65 * non-internal code. */
66enum
67{
69};
70
71typedef struct
72{
73 uint8_t ri; /* rendering intent */
74 uint8_t bp; /* black point compensation */
75 uint8_t op; /* overprinting */
76 uint8_t opm; /* overprint mode */
78
80
85int fz_lookup_rendering_intent(const char *name);
86
92const char *fz_rendering_intent_name(int ri);
93
102enum { FZ_MAX_COLORS = 32 };
103
109enum { FZ_MAX_SAMPLES = 1 << 30 };
110
122
123enum
124{
130};
131
144fz_colorspace *fz_new_colorspace(fz_context *ctx, enum fz_colorspace_type type, int flags, int n, const char *name);
145
152
160
179fz_colorspace *fz_new_indexed_colorspace(fz_context *ctx, fz_colorspace *base, int high, unsigned char *lookup);
180
196
197
206fz_colorspace *fz_new_cal_gray_colorspace(fz_context *ctx, float wp[3], float bp[3], float gamma);
207
216fz_colorspace *fz_new_cal_rgb_colorspace(fz_context *ctx, float wp[3], float bp[3], float gamma[3], float matrix[9]);
217
222
230
235
240
245
251
266
270void fz_colorspace_digest(fz_context *ctx, fz_colorspace *cs, unsigned char digest[16]);
271
277
289
301
309void fz_colorspace_name_colorant(fz_context *ctx, fz_colorspace *cs, int n, const char *name);
310
317
318/* Color conversion */
319
324void fz_clamp_color(fz_context *ctx, fz_colorspace *cs, const float *in, float *out);
325
331void fz_convert_color(fz_context *ctx, fz_colorspace *ss, const float *sv, fz_colorspace *ds, float *dv, fz_colorspace *is, fz_color_params params);
332
333/* Default (fallback) colorspace handling */
334
346
359
367
377
386
400
413
414/* Implementation details: subject to change. */
415
417{
420 int flags;
421 int n;
422 char *name;
423 union {
424#if FZ_ENABLE_ICC
425 struct {
426 fz_buffer *buffer;
427 unsigned char md5[16];
428 fz_icc_profile *profile;
429 } icc;
430#endif
431 struct {
433 int high;
434 unsigned char *lookup;
436 struct {
438 void (*eval)(fz_context *ctx, void *tint, const float *s, int sn, float *d, int dn);
439 void (*drop)(fz_context *ctx, void *tint);
440 void *tint;
443 } u;
444};
445
447
448#endif
fz_colorspace * fz_device_rgb(fz_context *ctx)
fz_colorspace * fz_device_gray(fz_context *ctx)
fz_default_colorspaces * fz_new_default_colorspaces(fz_context *ctx)
const char * fz_rendering_intent_name(int ri)
int fz_colorspace_is_device_n(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_device_n_has_only_cmyk(fz_context *ctx, fz_colorspace *cs)
fz_colorspace * fz_device_bgr(fz_context *ctx)
@ FZ_RI_IN_SOFTMASK
Definition color.h:68
int fz_lookup_rendering_intent(const char *name)
int fz_colorspace_is_gray(fz_context *ctx, fz_colorspace *cs)
@ FZ_COLORSPACE_HAS_CMYK_AND_SPOTS
Definition color.h:129
@ FZ_COLORSPACE_IS_ICC
Definition color.h:126
@ FZ_COLORSPACE_HAS_CMYK
Definition color.h:127
@ FZ_COLORSPACE_IS_DEVICE
Definition color.h:125
@ FZ_COLORSPACE_HAS_SPOTS
Definition color.h:128
int fz_colorspace_is_icc(fz_context *ctx, fz_colorspace *cs)
fz_colorspace * fz_default_cmyk(fz_context *ctx, const fz_default_colorspaces *default_cs)
fz_colorspace * fz_new_indexed_colorspace(fz_context *ctx, fz_colorspace *base, int high, unsigned char *lookup)
int fz_is_valid_blend_colorspace(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_is_indexed(fz_context *ctx, fz_colorspace *cs)
void fz_set_default_output_intent(fz_context *ctx, fz_default_colorspaces *default_cs, fz_colorspace *cs)
fz_colorspace * fz_device_lab(fz_context *ctx)
void fz_drop_default_colorspaces(fz_context *ctx, fz_default_colorspaces *default_cs)
fz_default_colorspaces * fz_clone_default_colorspaces(fz_context *ctx, fz_default_colorspaces *base)
fz_colorspace * fz_device_cmyk(fz_context *ctx)
int fz_colorspace_is_lab_icc(fz_context *ctx, fz_colorspace *cs)
const char * fz_colorspace_name(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_is_device_gray(fz_context *ctx, fz_colorspace *cs)
FZ_DATA const fz_color_params fz_default_color_params
@ FZ_MAX_SAMPLES
Definition color.h:109
fz_default_colorspaces * fz_keep_default_colorspaces(fz_context *ctx, fz_default_colorspaces *default_cs)
fz_colorspace * fz_default_output_intent(fz_context *ctx, const fz_default_colorspaces *default_cs)
int fz_colorspace_is_device(fz_context *ctx, fz_colorspace *cs)
void fz_clamp_color(fz_context *ctx, fz_colorspace *cs, const float *in, float *out)
void fz_set_default_gray(fz_context *ctx, fz_default_colorspaces *default_cs, fz_colorspace *cs)
@ FZ_MAX_COLORS
Definition color.h:102
void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace)
fz_colorspace * fz_default_rgb(fz_context *ctx, const fz_default_colorspaces *default_cs)
void fz_drop_colorspace_imp(fz_context *ctx, fz_storable *cs_)
fz_colorspace * fz_new_colorspace(fz_context *ctx, enum fz_colorspace_type type, int flags, int n, const char *name)
void fz_set_default_rgb(fz_context *ctx, fz_default_colorspaces *default_cs, fz_colorspace *cs)
int fz_colorspace_is_rgb(fz_context *ctx, fz_colorspace *cs)
void fz_colorspace_digest(fz_context *ctx, fz_colorspace *cs, unsigned char digest[16])
fz_colorspace * fz_default_gray(fz_context *ctx, const fz_default_colorspaces *default_cs)
fz_colorspace * fz_new_icc_colorspace(fz_context *ctx, enum fz_colorspace_type type, int flags, const char *name, fz_buffer *buf)
fz_colorspace * fz_keep_colorspace(fz_context *ctx, fz_colorspace *colorspace)
int fz_colorspace_is_device_cmyk(fz_context *ctx, fz_colorspace *cs)
fz_colorspace_type
Definition color.h:112
@ FZ_COLORSPACE_GRAY
Definition color.h:114
@ FZ_COLORSPACE_LAB
Definition color.h:118
@ FZ_COLORSPACE_INDEXED
Definition color.h:119
@ FZ_COLORSPACE_SEPARATION
Definition color.h:120
@ FZ_COLORSPACE_NONE
Definition color.h:113
@ FZ_COLORSPACE_CMYK
Definition color.h:117
@ FZ_COLORSPACE_BGR
Definition color.h:116
@ FZ_COLORSPACE_RGB
Definition color.h:115
fz_colorspace * fz_base_colorspace(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_is_subtractive(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_is_cmyk(fz_context *ctx, fz_colorspace *cs)
fz_colorspace * fz_new_cal_gray_colorspace(fz_context *ctx, float wp[3], float bp[3], float gamma)
fz_colorspace * fz_new_cal_rgb_colorspace(fz_context *ctx, float wp[3], float bp[3], float gamma[3], float matrix[9])
@ FZ_RI_ABSOLUTE_COLORIMETRIC
Definition color.h:60
@ FZ_RI_RELATIVE_COLORIMETRIC
Definition color.h:58
@ FZ_RI_PERCEPTUAL
Definition color.h:57
@ FZ_RI_SATURATION
Definition color.h:59
const char * fz_colorspace_colorant(fz_context *ctx, fz_colorspace *cs, int n)
int fz_colorspace_is_lab(fz_context *ctx, fz_colorspace *cs)
int fz_colorspace_n(fz_context *ctx, fz_colorspace *cs)
void fz_convert_color(fz_context *ctx, fz_colorspace *ss, const float *sv, fz_colorspace *ds, float *dv, fz_colorspace *is, fz_color_params params)
void fz_set_default_cmyk(fz_context *ctx, fz_default_colorspaces *default_cs, fz_colorspace *cs)
int fz_colorspace_device_n_has_cmyk(fz_context *ctx, fz_colorspace *cs)
void fz_colorspace_name_colorant(fz_context *ctx, fz_colorspace *cs, int n, const char *name)
#define FZ_DATA
Definition export.h:49
Definition buffer.h:41
Definition color.h:72
uint8_t ri
Definition color.h:73
uint8_t op
Definition color.h:75
uint8_t opm
Definition color.h:76
uint8_t bp
Definition color.h:74
Definition color.h:417
void(* eval)(fz_context *ctx, void *tint, const float *s, int sn, float *d, int dn)
Definition color.h:438
struct fz_colorspace::@131353350061053243055243124240361357026324205074::@212245030104130226034134070207310060270014002261 separation
fz_colorspace * base
Definition color.h:432
void * tint
Definition color.h:440
char * colorant[FZ_MAX_COLORS]
Definition color.h:441
int flags
Definition color.h:420
int high
Definition color.h:433
unsigned char * lookup
Definition color.h:434
fz_key_storable key_storable
Definition color.h:418
void(* drop)(fz_context *ctx, void *tint)
Definition color.h:439
int n
Definition color.h:421
char * name
Definition color.h:422
union fz_colorspace::@131353350061053243055243124240361357026324205074 u
struct fz_colorspace::@131353350061053243055243124240361357026324205074::@264302053047321370054060152354176012244200020053 indexed
enum fz_colorspace_type type
Definition color.h:419
Definition context.h:886
Definition color.h:339
fz_colorspace * rgb
Definition color.h:342
fz_colorspace * gray
Definition color.h:341
int refs
Definition color.h:340
fz_colorspace * cmyk
Definition color.h:343
fz_colorspace * oi
Definition color.h:344
Definition store.h:88
Definition pixmap.h:432
unsigned char flags
Definition pixmap.h:438
fz_colorspace * colorspace
Definition pixmap.h:442
unsigned char n
Definition pixmap.h:435
Definition store.h:76