Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_COLORSPACE_H
2
#define MUPDF_FITZ_COLORSPACE_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/store.h"
7
8
enum { FZ_MAX_COLORS = 32 };
9
10
/*
11
An fz_colorspace object represents an abstract colorspace. While
12
this should be treated as a black box by callers of the library at
13
this stage, know that it encapsulates knowledge of how to convert
14
colors to and from the colorspace, any lookup tables generated, the
15
number of components in the colorspace etc.
16
*/
17
typedef struct fz_colorspace_s fz_colorspace;
18
19
/*
20
fz_lookup_device_colorspace: Find a standard colorspace based upon
21
it's name.
22
*/
23
fz_colorspace *fz_lookup_device_colorspace(fz_context *ctx, char *name);
24
25
/*
26
fz_colorspace_is_indexed: Return true, iff a given colorspace is
27
indexed.
28
*/
29
int fz_colorspace_is_indexed(fz_context *ctx, fz_colorspace *cs);
30
31
/*
32
fz_device_gray: Get colorspace representing device specific gray.
33
*/
34
fz_colorspace *fz_device_gray(fz_context *ctx);
35
36
/*
37
fz_device_rgb: Get colorspace representing device specific rgb.
38
*/
39
fz_colorspace *fz_device_rgb(fz_context *ctx);
40
41
/*
42
fz_device_bgr: Get colorspace representing device specific bgr.
43
*/
44
fz_colorspace *fz_device_bgr(fz_context *ctx);
45
46
/*
47
fz_device_cmyk: Get colorspace representing device specific CMYK.
48
*/
49
fz_colorspace *fz_device_cmyk(fz_context *ctx);
50
51
/*
52
fz_set_device_gray: Set colorspace representing device specific gray.
53
*/
54
void fz_set_device_gray(fz_context *ctx, fz_colorspace *cs);
55
56
/*
57
fz_set_device_rgb: Set colorspace representing device specific rgb.
58
*/
59
void fz_set_device_rgb(fz_context *ctx, fz_colorspace *cs);
60
61
/*
62
fz_set_device_bgr: Set colorspace representing device specific bgr.
63
*/
64
void fz_set_device_bgr(fz_context *ctx, fz_colorspace *cs);
65
66
/*
67
fz_set_device_cmyk: Set colorspace representing device specific CMYK.
68
*/
69
void fz_set_device_cmyk(fz_context *ctx, fz_colorspace *cs);
70
71
struct fz_colorspace_s
72
{
73
fz_storable storable;
74
unsigned int size;
75
char name[16];
76
int n;
77
void (*to_rgb)(fz_context *ctx, fz_colorspace *, const float *src, float *rgb);
78
void (*from_rgb)(fz_context *ctx, fz_colorspace *, const float *rgb, float *dst);
79
void (*free_data)(fz_context *Ctx, fz_colorspace *);
80
void *data;
81
};
82
83
fz_colorspace *fz_new_colorspace(fz_context *ctx, char *name, int n);
84
fz_colorspace *fz_new_indexed_colorspace(fz_context *ctx, fz_colorspace *base, int high, unsigned char *lookup);
85
fz_colorspace *fz_keep_colorspace(fz_context *ctx, fz_colorspace *colorspace);
86
void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace);
87
void fz_drop_colorspace_imp(fz_context *ctx, fz_storable *colorspace);
88
89
void fz_convert_color(fz_context *ctx, fz_colorspace *dsts, float *dstv, fz_colorspace *srcs, const float *srcv);
90
91
void fz_new_colorspace_context(fz_context *ctx);
92
fz_colorspace_context *fz_keep_colorspace_context(fz_context *ctx);
93
void fz_drop_colorspace_context(fz_context *ctx);
94
95
typedef struct fz_color_converter_s fz_color_converter;
96
97
/* This structure is public because it allows us to avoid dynamic allocations.
98
* Callers should only rely on the convert entry - the rest of the structure
99
* is subject to change without notice.
100
*/
101
struct fz_color_converter_s
102
{
103
void (*convert)(fz_context *, fz_color_converter *, float *, const float *);
104
fz_colorspace *ds;
105
fz_colorspace *ss;
106
void *opaque;
107
};
108
109
void fz_lookup_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss);
110
111
void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss);
112
void fz_fin_cached_color_converter(fz_context *ctx, fz_color_converter *cc);
113
114
#endif
115
116