1 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
2 
3     Copyright (C) 2002-2015 by Jin-Hwan Cho and Shunsaku Hirata,
4     the dvipdfmx project team.
5 
6     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 */
22 
23 #ifndef _PDF_COLOR_H_
24 #define _PDF_COLOR_H_
25 
26 #include "pdfobj.h"
27 
28 #define PDF_COLORSPACE_TYPE_DEVICECMYK -4
29 #define PDF_COLORSPACE_TYPE_DEVICERGB  -3
30 #define PDF_COLORSPACE_TYPE_SPOT       -2
31 #define PDF_COLORSPACE_TYPE_DEVICEGRAY -1
32 #define PDF_COLORSPACE_TYPE_INVALID     0
33 #define PDF_COLORSPACE_TYPE_CALGRAY     1
34 #define PDF_COLORSPACE_TYPE_CIELAB      2
35 #define PDF_COLORSPACE_TYPE_CALRGB      3
36 #define PDF_COLORSPACE_TYPE_ICCBASED    4
37 
38 #define PDF_COLORSPACE_TYPE_CMYK  PDF_COLORSPACE_TYPE_DEVICECMYK
39 #define PDF_COLORSPACE_TYPE_RGB   PDF_COLORSPACE_TYPE_DEVICERGB
40 #define PDF_COLORSPACE_TYPE_GRAY  PDF_COLORSPACE_TYPE_DEVICEGRAY
41 
42 
43 #define PDF_COLOR_COMPONENT_MAX 4
44 
45 typedef struct
46 {
47   int    num_components;
48   char*  spot_color_name;
49   double values[PDF_COLOR_COMPONENT_MAX];
50 } pdf_color;
51 
52 extern void       pdf_color_set_verbose   (void);
53 
54 extern int        pdf_color_rgbcolor      (pdf_color *color,
55                                            double r, double g, double b);
56 extern int        pdf_color_cmykcolor     (pdf_color *color,
57                                            double c, double m, double y, double k);
58 extern int        pdf_color_graycolor     (pdf_color *color, double g);
59 
60 extern int        pdf_color_spotcolor     (pdf_color *color, char* color_name, double c);
61 
62 extern void       pdf_color_copycolor     (pdf_color *color1, const pdf_color *color2);
63 
64 #define pdf_color_black(c)   pdf_color_graycolor(c, 0.0);
65 #define pdf_color_white(c)   pdf_color_graycolor(c, 1.0);
66 
67 extern void       pdf_color_brighten_color (pdf_color *dst, const pdf_color *src, double f);
68 
69 extern int        pdf_color_type          (const pdf_color *color);
70 extern int        pdf_color_compare       (const pdf_color *color1, const pdf_color *color2);
71 extern int        pdf_color_to_string     (const pdf_color *color, char *buffer, char mask);
72 
73 extern int        pdf_color_is_white      (const pdf_color *color);
74 extern int        pdf_color_is_valid      (const pdf_color *color);
75 
76 /* Not check size */
77 extern pdf_obj *iccp_get_rendering_intent (const void *profile, long proflen);
78 extern int      iccp_check_colorspace     (int colortype,
79 					   const void *profile, long proflen);
80 
81 /* returns colorspace ID */
82 extern int      iccp_load_profile (const char *ident,
83 				   const void *profile, long proflen);
84 
85 extern void     pdf_init_colors  (void);
86 extern void     pdf_close_colors (void);
87 
88 extern pdf_obj *pdf_get_colorspace_reference      (int cspc_id);
89 #if 0
90 extern int      pdf_get_colorspace_num_components (int cspc_id);
91 extern int      pdf_get_colorspace_subtype        (int cspc_id);
92 
93 /* Not working */
94 extern int      pdf_colorspace_load_ICCBased      (const char *ident,
95 						   const char *profile_filename);
96 #endif
97 
98 /* Color special
99  * See remark in spc_color.c.
100  */
101 extern void     pdf_color_set   (pdf_color *sc, pdf_color *fc);
102 extern void     pdf_color_set_default (const pdf_color *color);
103 extern void     pdf_color_push  (pdf_color *sc, pdf_color *fc);
104 extern void     pdf_color_pop   (void);
105 
106 /* Color stack
107  */
108 extern void     pdf_color_clear_stack (void);
109 extern void     pdf_color_get_current (pdf_color **sc, pdf_color **fc);
110 
111 #if 0
112 /* Reinstall color */
113 extern void     pdf_dev_preserve_color(void);
114 #endif
115 
116 #endif /* _PDF_COLOR_H_ */
117