1/*---------------------------------------------------------------------------* 2 | PDFlib - A library for generating PDF on the fly | 3 +---------------------------------------------------------------------------+ 4 | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | 5 +---------------------------------------------------------------------------+ 6 | | 7 | This software is subject to the PDFlib license. It is NOT in the | 8 | public domain. Extended versions and commercial licenses are | 9 | available, please check http://www.pdflib.com. | 10 | | 11 *---------------------------------------------------------------------------*/ 12 13/* $Id: p_color.h 14574 2005-10-29 16:27:43Z bonefish $ 14 * 15 * PDFlib color definitions 16 * 17 */ 18 19#ifndef P_COLOR_H 20#define P_COLOR_H 21 22typedef enum { 23 NoColor = -1, DeviceGray = 0, DeviceRGB, DeviceCMYK, 24 CalGray, CalRGB, Lab, ICCBased, 25 Indexed, PatternCS, Separation, DeviceN 26} pdf_colorspacetype; 27 28/* 29 * These are treated specially in the global colorspace list, and are not 30 * written as /ColorSpace resource since we always specify them directly. 31 * Pattern colorspace with base == pdc_undef means PaintType == 1. 32 */ 33#define PDF_SIMPLE_COLORSPACE(cs) \ 34 ((cs)->type == DeviceGray || \ 35 (cs)->type == DeviceRGB || \ 36 (cs)->type == DeviceCMYK || \ 37 ((cs)->type == PatternCS && cs->val.pattern.base == pdc_undef)) 38 39/* Rendering Intents */ 40typedef enum { 41 AutoIntent = 0, 42 AbsoluteColorimetric, 43 RelativeColorimetric, 44 Saturation, 45 Perceptual 46} pdf_renderingintent; 47 48/* BlendModes */ 49typedef enum { 50 BM_None = 0, 51 BM_Normal = 1<<0, 52 BM_Multiply = 1<<1, 53 BM_Screen = 1<<2, 54 BM_Overlay = 1<<3, 55 BM_Darken = 1<<4, 56 BM_Lighten = 1<<5, 57 BM_ColorDodge = 1<<6, 58 BM_ColorBurn = 1<<7, 59 BM_HardLight = 1<<8, 60 BM_SoftLight = 1<<9, 61 BM_Difference = 1<<10, 62 BM_Exclusion = 1<<11, 63 BM_Hue = 1<<12, 64 BM_Saturation = 1<<13, 65 BM_Color = 1<<14, 66 BM_Luminosity = 1<<15 67} pdf_blendmode; 68 69 70struct pdf_pattern_s { 71 pdc_id obj_id; /* object id of this pattern */ 72 int painttype; /* colored (1) or uncolored (2) */ 73 pdc_bool used_on_current_page; /* this pattern used on current page */ 74}; 75 76typedef enum { 77 pdf_none = 0, 78 pdf_fill, 79 pdf_stroke, 80 pdf_fillstroke 81} pdf_drawmode; 82 83typedef pdc_byte pdf_colormap[256][3]; 84 85typedef struct pdf_colorspace_s pdf_colorspace; 86 87typedef struct { 88 int cs; /* slot of underlying color space */ 89 90 union { 91 float gray; /* DeviceGray */ 92 int pattern; /* Pattern */ 93 int idx; /* Indexed */ 94 struct { /* DeviceRGB */ 95 float r; 96 float g; 97 float b; 98 } rgb; 99 struct { /* DeviceCMYK */ 100 float c; 101 float m; 102 float y; 103 float k; 104 } cmyk; 105 } val; 106} pdf_color; 107 108struct pdf_colorspace_s { 109 pdf_colorspacetype type; /* color space type */ 110 111 union { 112 struct { /* Indexed */ 113 int base; /* base color space */ 114 pdf_colormap *colormap; /* pointer to colormap */ 115 pdc_bool colormap_done; /* colormap already written to output */ 116 int palette_size; /* # of palette entries (not bytes!) */ 117 pdc_id colormap_id; /* object id of colormap */ 118 } indexed; 119 120 struct { /* Pattern */ 121 int base; /* base color space for PaintType 2 */ 122 } pattern; 123 124 } val; 125 126 pdc_id obj_id; /* object id of this colorspace */ 127 pdc_bool used_on_current_page; /* this resource used on current page */ 128}; 129 130typedef struct { 131 pdf_color fill; 132 pdf_color stroke; 133} pdf_cstate; 134 135/* p_color.c */ 136void pdf_init_cstate(PDF *p); 137void pdf_init_colorspaces(PDF *p); 138void pdf_write_page_colorspaces(PDF *p); 139void pdf_write_function_dict(PDF *p, pdf_color *c0, pdf_color *c1, float N); 140void pdf_write_doc_colorspaces(PDF *p); 141void pdf_write_colorspace(PDF *p, int slot, pdc_bool direct); 142void pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode mode); 143void pdf_set_color_values(PDF *p, pdf_color *c, pdf_drawmode drawmode); 144int pdf_add_colorspace(PDF *p, pdf_colorspace *cs, pdc_bool inuse); 145void pdf_cleanup_colorspaces(PDF *p); 146void pdf_write_colormap(PDF *p, int slot); 147int pdf_color_components(PDF *p, int slot); 148int pdf__makespotcolor(PDF *p, const char *spotname); 149void pdf__setcolor(PDF *p, const char *fstype, const char *colorspace, 150 float c1, float c2, float c3, float c4); 151 152 153/* p_pattern.c */ 154void pdf_grow_pattern(PDF *p); 155#endif /* P_COLOR_H */ 156