comparison mupdf-source/source/fitz/color-imp.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2021 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 FITZ_COLOR_IMP_H
24 #define FITZ_COLOR_IMP_H
25
26 #include "mupdf/fitz.h"
27
28 typedef struct fz_color_converter fz_color_converter;
29
30 /* Color management engine */
31
32 #if FZ_ENABLE_ICC
33
34 /*
35 Create ICC profile from PDF calGray and calRGB definitions
36 */
37 fz_buffer *fz_new_icc_data_from_cal(fz_context *ctx, float wp[3], float bp[3], float *gamma, float matrix[9], int n);
38
39 /*
40 Opaque type for a link (transform) generated between ICC
41 profiles.
42 */
43 typedef struct fz_icc_link fz_icc_link;
44
45 void fz_new_icc_context(fz_context *ctx);
46 void fz_drop_icc_context(fz_context *ctx);
47 fz_icc_profile *fz_new_icc_profile(fz_context *ctx, unsigned char *data, size_t size);
48 void fz_drop_icc_profile(fz_context *ctx, fz_icc_profile *profile);
49 void fz_icc_profile_name(fz_context *ctx, fz_icc_profile *profile, char *name, size_t size);
50 int fz_icc_profile_components(fz_context *ctx, fz_icc_profile *profile);
51 int fz_icc_profile_is_lab(fz_context *ctx, fz_icc_profile *profile);
52 fz_icc_link *fz_new_icc_link(fz_context *ctx,
53 fz_colorspace *src, int src_extras,
54 fz_colorspace *dst, int dst_extras,
55 fz_colorspace *prf,
56 fz_color_params color_params,
57 int format,
58 int copy_spots,
59 int premult);
60 void fz_drop_icc_link_imp(fz_context *ctx, fz_storable *link);
61 void fz_drop_icc_link(fz_context *ctx, fz_icc_link *link);
62 fz_icc_link *fz_find_icc_link(fz_context *ctx,
63 fz_colorspace *src, int src_extras,
64 fz_colorspace *dst, int dst_extras,
65 fz_colorspace *prf,
66 fz_color_params color_params,
67 int format,
68 int copy_spots,
69 int premult);
70 void fz_icc_transform_color(fz_context *ctx, fz_color_converter *cc, const float *src, float *dst);
71 void fz_icc_transform_pixmap(fz_context *ctx, fz_icc_link *link, const fz_pixmap *src, fz_pixmap *dst, int copy_spots);
72
73 #endif
74
75 typedef void (fz_color_convert_fn)(fz_context *ctx, fz_color_converter *cc, const float *src, float *dst);
76
77 struct fz_color_converter
78 {
79 fz_color_convert_fn *convert;
80 fz_color_convert_fn *convert_via;
81 fz_colorspace *ds;
82 fz_separations *dseps;
83 int dst_n;
84 fz_colorspace *ss;
85 fz_colorspace *ss_via;
86 void *opaque;
87 #if FZ_ENABLE_ICC
88 fz_icc_link *link;
89 #endif
90 };
91
92 struct fz_colorspace_context
93 {
94 int ctx_refs;
95 fz_colorspace *gray, *rgb, *bgr, *cmyk, *lab;
96 #if FZ_ENABLE_ICC
97 void *icc_instance;
98 #endif
99 };
100
101 void fz_drop_colorspace_store_key(fz_context *ctx, fz_colorspace *cs);
102 fz_colorspace *fz_keep_colorspace_store_key(fz_context *ctx, fz_colorspace *cs);
103
104 void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ss, fz_colorspace *ds, fz_separations *seps, fz_colorspace *is, fz_color_params params);
105 void fz_fin_cached_color_converter(fz_context *ctx, fz_color_converter *cc);
106 fz_color_convert_fn *fz_lookup_fast_color_converter(fz_context *ctx, fz_colorspace *ss, fz_colorspace *ds);
107 void fz_find_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ss, fz_colorspace *ds, fz_separations *seps, fz_colorspace *is, fz_color_params params);
108 void fz_drop_color_converter(fz_context *ctx, fz_color_converter *cc);
109
110 /*
111 Color convert a pixmap. The passing of default_cs is needed due
112 to the base cs of the image possibly needing to be treated as
113 being in one of the page default color spaces.
114 */
115 void fz_convert_pixmap_samples(fz_context *ctx, const fz_pixmap *src, fz_pixmap *dst, fz_colorspace *prf, const fz_default_colorspaces *default_cs, fz_color_params color_params, int copy_spots);
116 void fz_fast_any_to_alpha(fz_context *ctx, const fz_pixmap *src, fz_pixmap *dst, int copy_spots);
117 void fz_convert_fast_pixmap_samples(fz_context *ctx, const fz_pixmap *src, fz_pixmap *dst, int copy_spots);
118 void fz_convert_slow_pixmap_samples(fz_context *ctx, const fz_pixmap *src, fz_pixmap *dst, fz_colorspace *prf, fz_color_params params, int copy_spots);
119
120 /**
121 Attempt to init a color converter to work by copying separation values.
122 */
123 int
124 fz_init_separation_copy_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ss, fz_colorspace *ds, fz_separations *dseps, fz_colorspace *is, fz_color_params params);
125
126
127 #endif