1
//========================================================================
5
// Copyright 1996-2002 Glyph & Cog, LLC
7
//========================================================================
14
#ifdef USE_GCC_PRAGMAS
26
//------------------------------------------------------------------------
28
//------------------------------------------------------------------------
30
#define gfxColorMaxComps funcMaxOutputs
33
double c[gfxColorMaxComps];
36
//------------------------------------------------------------------------
38
//------------------------------------------------------------------------
44
//------------------------------------------------------------------------
46
//------------------------------------------------------------------------
52
//------------------------------------------------------------------------
54
//------------------------------------------------------------------------
56
enum GfxColorSpaceMode {
74
virtual ~GfxColorSpace();
75
virtual GfxColorSpace *copy() const = 0;
76
virtual GfxColorSpaceMode getMode() const = 0;
78
// Construct a color space. Returns NULL if unsuccessful.
79
static GfxColorSpace *parse(Object *csObj);
81
// Convert to gray, RGB, or CMYK.
82
virtual void getGray(const GfxColor *color, double *gray) const = 0;
83
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const = 0;
84
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const = 0;
86
// Return the number of color components.
87
virtual int getNComps() const = 0;
89
// Return the default ranges for each component, assuming an image
90
// with a max pixel value of <maxImgPixel>.
91
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
92
int maxImgPixel) const;
97
//------------------------------------------------------------------------
98
// GfxDeviceGrayColorSpace
99
//------------------------------------------------------------------------
101
class GfxDeviceGrayColorSpace: public GfxColorSpace {
104
GfxDeviceGrayColorSpace();
105
virtual ~GfxDeviceGrayColorSpace();
106
virtual GfxColorSpace *copy() const;
107
virtual GfxColorSpaceMode getMode() const { return csDeviceGray; }
109
virtual void getGray(const GfxColor *color, double *gray) const;
110
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
111
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
113
virtual int getNComps() const { return 1; }
118
//------------------------------------------------------------------------
119
// GfxCalGrayColorSpace
120
//------------------------------------------------------------------------
122
class GfxCalGrayColorSpace: public GfxColorSpace {
125
GfxCalGrayColorSpace();
126
virtual ~GfxCalGrayColorSpace();
127
virtual GfxColorSpace *copy() const;
128
virtual GfxColorSpaceMode getMode() const { return csCalGray; }
130
// Construct a CalGray color space. Returns NULL if unsuccessful.
131
static GfxColorSpace *parse(Array *arr);
133
virtual void getGray(const GfxColor *color, double *gray) const;
134
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
135
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
137
virtual int getNComps() const { return 1; }
139
// CalGray-specific access.
140
double getWhiteX() const { return whiteX; }
141
double getWhiteY() const { return whiteY; }
142
double getWhiteZ() const { return whiteZ; }
143
double getBlackX() const { return blackX; }
144
double getBlackY() const { return blackY; }
145
double getBlackZ() const { return blackZ; }
146
double getGamma() const { return gamma; }
150
double whiteX, whiteY, whiteZ; // white point
151
double blackX, blackY, blackZ; // black point
152
double gamma; // gamma value
155
//------------------------------------------------------------------------
156
// GfxDeviceRGBColorSpace
157
//------------------------------------------------------------------------
159
class GfxDeviceRGBColorSpace: public GfxColorSpace {
162
GfxDeviceRGBColorSpace();
163
virtual ~GfxDeviceRGBColorSpace();
164
virtual GfxColorSpace *copy() const;
165
virtual GfxColorSpaceMode getMode() const { return csDeviceRGB; }
167
virtual void getGray(const GfxColor *color, double *gray) const;
168
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
169
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
171
virtual int getNComps() const{ return 3; }
176
//------------------------------------------------------------------------
177
// GfxCalRGBColorSpace
178
//------------------------------------------------------------------------
180
class GfxCalRGBColorSpace: public GfxColorSpace {
183
GfxCalRGBColorSpace();
184
virtual ~GfxCalRGBColorSpace();
185
virtual GfxColorSpace *copy() const;
186
virtual GfxColorSpaceMode getMode() const { return csCalRGB; }
188
// Construct a CalRGB color space. Returns NULL if unsuccessful.
189
static GfxColorSpace *parse(Array *arr);
191
virtual void getGray(const GfxColor *color, double *gray) const;
192
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
193
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
195
virtual int getNComps() const { return 3; }
197
// CalRGB-specific access.
198
double getWhiteX() const { return whiteX; }
199
double getWhiteY() const { return whiteY; }
200
double getWhiteZ() const { return whiteZ; }
201
double getBlackX() const { return blackX; }
202
double getBlackY() const { return blackY; }
203
double getBlackZ() const { return blackZ; }
204
double getGammaR() const { return gammaR; }
205
double getGammaG() const { return gammaG; }
206
double getGammaB() const { return gammaB; }
207
const double *getMatrix() const { return mat; }
211
double whiteX, whiteY, whiteZ; // white point
212
double blackX, blackY, blackZ; // black point
213
double gammaR, gammaG, gammaB; // gamma values
214
double mat[9]; // ABC -> XYZ transform matrix
217
//------------------------------------------------------------------------
218
// GfxDeviceCMYKColorSpace
219
//------------------------------------------------------------------------
221
class GfxDeviceCMYKColorSpace: public GfxColorSpace {
224
GfxDeviceCMYKColorSpace();
225
virtual ~GfxDeviceCMYKColorSpace();
226
virtual GfxColorSpace *copy() const;
227
virtual GfxColorSpaceMode getMode() const { return csDeviceCMYK; }
229
virtual void getGray(const GfxColor *color, double *gray) const;
230
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
231
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
233
virtual int getNComps() const { return 4; }
238
//------------------------------------------------------------------------
240
//------------------------------------------------------------------------
242
class GfxLabColorSpace: public GfxColorSpace {
246
virtual ~GfxLabColorSpace();
247
virtual GfxColorSpace *copy() const;
248
virtual GfxColorSpaceMode getMode() const { return csLab; }
250
// Construct a Lab color space. Returns NULL if unsuccessful.
251
static GfxColorSpace *parse(Array *arr);
253
virtual void getGray(const GfxColor *color, double *gray) const;
254
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
255
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
257
virtual int getNComps() const { return 3; }
259
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
260
int maxImgPixel) const;
262
// Lab-specific access.
263
double getWhiteX() const { return whiteX; }
264
double getWhiteY() const { return whiteY; }
265
double getWhiteZ() const { return whiteZ; }
266
double getBlackX() const { return blackX; }
267
double getBlackY() const { return blackY; }
268
double getBlackZ() const { return blackZ; }
269
double getAMin() const { return aMin; }
270
double getAMax() const { return aMax; }
271
double getBMin() const { return bMin; }
272
double getBMax() const { return bMax; }
276
double whiteX, whiteY, whiteZ; // white point
277
double blackX, blackY, blackZ; // black point
278
double aMin, aMax, bMin, bMax; // range for the a and b components
279
double kr, kg, kb; // gamut mapping mulitpliers
282
//------------------------------------------------------------------------
283
// GfxICCBasedColorSpace
284
//------------------------------------------------------------------------
286
class GfxICCBasedColorSpace: public GfxColorSpace {
289
GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
290
const Ref *iccProfileStreamA);
291
virtual ~GfxICCBasedColorSpace();
292
virtual GfxColorSpace *copy() const;
293
virtual GfxColorSpaceMode getMode() const { return csICCBased; }
295
// Construct an ICCBased color space. Returns NULL if unsuccessful.
296
static GfxColorSpace *parse(Array *arr);
298
virtual void getGray(const GfxColor *color, double *gray) const;
299
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
300
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
302
virtual int getNComps() const { return nComps; }
304
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
305
int maxImgPixel) const;
307
// ICCBased-specific access.
308
const GfxColorSpace *getAlt() const { return alt; }
312
int nComps; // number of color components (1, 3, or 4)
313
GfxColorSpace *alt; // alternate color space
314
double rangeMin[4]; // min values for each component
315
double rangeMax[4]; // max values for each component
316
Ref iccProfileStream; // the ICC profile
319
//------------------------------------------------------------------------
320
// GfxIndexedColorSpace
321
//------------------------------------------------------------------------
323
class GfxIndexedColorSpace: public GfxColorSpace {
326
GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
327
virtual ~GfxIndexedColorSpace();
328
virtual GfxColorSpace *copy() const;
329
virtual GfxColorSpaceMode getMode() const { return csIndexed; }
331
// Construct a Lab color space. Returns NULL if unsuccessful.
332
static GfxColorSpace *parse(Array *arr);
334
virtual void getGray(const GfxColor *color, double *gray) const;
335
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
336
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
338
virtual int getNComps() const { return 1; }
340
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
341
int maxImgPixel) const;
343
// Indexed-specific access.
344
const GfxColorSpace *getBase() const { return base; }
345
int getIndexHigh() const { return indexHigh; }
346
const Guchar *getLookup() const { return lookup; }
350
GfxColorSpace *base; // base color space
351
int indexHigh; // max pixel value
352
Guchar *lookup; // lookup table
355
//------------------------------------------------------------------------
356
// GfxSeparationColorSpace
357
//------------------------------------------------------------------------
359
class GfxSeparationColorSpace: public GfxColorSpace {
362
GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
364
virtual ~GfxSeparationColorSpace();
365
virtual GfxColorSpace *copy() const;
366
virtual GfxColorSpaceMode getMode() const { return csSeparation; }
368
// Construct a Separation color space. Returns NULL if unsuccessful.
369
static GfxColorSpace *parse(Array *arr);
371
virtual void getGray(const GfxColor *color, double *gray) const;
372
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
373
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
375
virtual int getNComps() const { return 1; }
377
// Separation-specific access.
378
const GString *getName() const { return name; }
379
const GfxColorSpace *getAlt() const { return alt; }
380
const Function *getFunc() const { return func; }
384
GString *name; // colorant name
385
GfxColorSpace *alt; // alternate color space
386
Function *func; // tint transform (into alternate color space)
389
//------------------------------------------------------------------------
390
// GfxDeviceNColorSpace
391
//------------------------------------------------------------------------
393
class GfxDeviceNColorSpace: public GfxColorSpace {
396
GfxDeviceNColorSpace(int nComps, GfxColorSpace *alt, Function *func);
397
virtual ~GfxDeviceNColorSpace();
398
virtual GfxColorSpace *copy() const;
399
virtual GfxColorSpaceMode getMode() const { return csDeviceN; }
401
// Construct a DeviceN color space. Returns NULL if unsuccessful.
402
static GfxColorSpace *parse(Array *arr);
404
virtual void getGray(const GfxColor *color, double *gray) const;
405
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
406
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
408
virtual int getNComps() const { return nComps; }
410
// DeviceN-specific access.
411
const GString *getColorantName(int i) const { return names[i]; }
412
const GfxColorSpace *getAlt() const { return alt; }
413
const Function *getTintTransformFunc() const { return func; }
417
int nComps; // number of components
418
GString // colorant names
419
*names[gfxColorMaxComps];
420
GfxColorSpace *alt; // alternate color space
421
Function *func; // tint transform (into alternate color space)
425
//------------------------------------------------------------------------
426
// GfxPatternColorSpace
427
//------------------------------------------------------------------------
429
class GfxPatternColorSpace: public GfxColorSpace {
432
GfxPatternColorSpace(GfxColorSpace *underA);
433
virtual ~GfxPatternColorSpace();
434
virtual GfxColorSpace *copy() const;
435
virtual GfxColorSpaceMode getMode() const { return csPattern; }
437
// Construct a Pattern color space. Returns NULL if unsuccessful.
438
static GfxColorSpace *parse(Array *arr);
440
virtual void getGray(const GfxColor *color, double *gray) const;
441
virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
442
virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
444
virtual int getNComps() const { return 0; }
446
// Pattern-specific access.
447
const GfxColorSpace *getUnder() const { return under; }
451
GfxColorSpace *under; // underlying color space (for uncolored
455
//------------------------------------------------------------------------
457
//------------------------------------------------------------------------
462
GfxPattern(int typeA);
463
virtual ~GfxPattern();
465
static GfxPattern *parse(Object *obj);
467
virtual GfxPattern *copy() = 0;
469
int getType() { return type; }
476
//------------------------------------------------------------------------
478
//------------------------------------------------------------------------
480
class GfxTilingPattern: public GfxPattern {
483
GfxTilingPattern(Dict *streamDict, Object *stream);
484
virtual ~GfxTilingPattern();
486
virtual GfxPattern *copy();
488
int getPaintType() { return paintType; }
489
int getTilingType() { return tilingType; }
490
double *getBBox() { return bbox; }
491
double getXStep() { return xStep; }
492
double getYStep() { return yStep; }
494
{ return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
495
double *getMatrix() { return matrix; }
496
Object *getContentStream() { return &contentStream; }
500
GfxTilingPattern(GfxTilingPattern *pat);
508
Object contentStream;
511
//------------------------------------------------------------------------
513
//------------------------------------------------------------------------
519
virtual ~GfxShading();
521
static GfxShading *parse(Object *obj);
523
int getType() { return type; }
524
GfxColorSpace *getColorSpace() { return colorSpace; }
525
GfxColor *getBackground() { return &background; }
526
GBool getHasBackground() { return hasBackground; }
527
void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
528
{ *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
529
GBool getHasBBox() { return hasBBox; }
534
GfxColorSpace *colorSpace;
537
double xMin, yMin, xMax, yMax;
541
//------------------------------------------------------------------------
543
//------------------------------------------------------------------------
545
class GfxAxialShading: public GfxShading {
548
GfxAxialShading(double x0A, double y0A,
549
double x1A, double y1A,
550
double t0A, double t1A,
551
Function **funcsA, int nFuncsA,
552
GBool extend0A, GBool extend1A);
553
virtual ~GfxAxialShading();
555
static GfxAxialShading *parse(Dict *dict);
557
void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
558
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
559
double getDomain0() { return t0; }
560
double getDomain1() { return t1; }
561
void getColor(double t, GfxColor *color);
562
GBool getExtend0() { return extend0; }
563
GBool getExtend1() { return extend1; }
567
double x0, y0, x1, y1;
569
Function *funcs[gfxColorMaxComps];
571
GBool extend0, extend1;
574
//------------------------------------------------------------------------
576
//------------------------------------------------------------------------
578
class GfxRadialShading: public GfxShading {
581
GfxRadialShading(double x0A, double y0A, double r0A,
582
double x1A, double y1A, double r1A,
583
double t0A, double t1A,
584
Function **funcsA, int nFuncsA,
585
GBool extend0A, GBool extend1A);
586
virtual ~GfxRadialShading();
588
static GfxRadialShading *parse(Dict *dict);
590
void getCoords(double *x0A, double *y0A, double *r0A,
591
double *x1A, double *y1A, double *r1A)
592
{ *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
593
double getDomain0() { return t0; }
594
double getDomain1() { return t1; }
595
void getColor(double t, GfxColor *color);
596
GBool getExtend0() { return extend0; }
597
GBool getExtend1() { return extend1; }
601
double x0, y0, r0, x1, y1, r1;
603
Function *funcs[gfxColorMaxComps];
605
GBool extend0, extend1;
608
//------------------------------------------------------------------------
610
//------------------------------------------------------------------------
612
class GfxImageColorMap {
616
GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
621
// Is color map valid?
622
GBool isOk() { return ok; }
624
// Get the color space.
625
GfxColorSpace *getColorSpace() { return colorSpace; }
627
// Get stream decoding info.
628
int getNumPixelComps() { return nComps; }
629
int getBits() { return bits; }
632
double getDecodeLow(int i) { return decodeLow[i]; }
633
double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
635
// Convert an image pixel to a color.
636
void getGray(Guchar *x, double *gray);
637
void getRGB(Guchar *x, GfxRGB *rgb);
638
void getCMYK(Guchar *x, GfxCMYK *cmyk);
642
GfxColorSpace *colorSpace; // the image color space
643
int bits; // bits per component
644
int nComps; // number of components in a pixel
645
const GfxColorSpace *colorSpace2; // secondary color space
646
int nComps2; // number of components in colorSpace2
647
double *lookup; // lookup table
648
double // minimum values for each component
649
decodeLow[gfxColorMaxComps];
650
double // max - min value for each component
651
decodeRange[gfxColorMaxComps];
655
//------------------------------------------------------------------------
656
// GfxSubpath and GfxPath
657
//------------------------------------------------------------------------
663
GfxSubpath(double x1, double y1);
669
GfxSubpath *copy() { return new GfxSubpath(this); }
672
int getNumPoints() { return n; }
673
double getX(int i) { return x[i]; }
674
double getY(int i) { return y[i]; }
675
GBool getCurve(int i) { return curve[i]; }
678
double getLastX() { return x[n-1]; }
679
double getLastY() { return y[n-1]; }
681
// Add a line segment.
682
void lineTo(double x1, double y1);
684
// Add a Bezier curve.
685
void curveTo(double x1, double y1, double x2, double y2,
686
double x3, double y3);
688
// Close the subpath.
690
GBool isClosed() { return closed; }
694
double *x, *y; // points
695
GBool *curve; // curve[i] => point i is a control point
696
// for a Bezier curve
697
int n; // number of points
698
int size; // size of x/y arrays
699
GBool closed; // set if path is closed
701
GfxSubpath(GfxSubpath *subpath);
715
{ return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
717
// Is there a current point?
718
GBool isCurPt() { return n > 0 || justMoved; }
720
// Is the path non-empty, i.e., is there at least one segment?
721
GBool isPath() { return n > 0; }
724
int getNumSubpaths() { return n; }
725
GfxSubpath *getSubpath(int i) { return subpaths[i]; }
727
// Get last point on last subpath.
728
double getLastX() { return subpaths[n-1]->getLastX(); }
729
double getLastY() { return subpaths[n-1]->getLastY(); }
731
// Move the current point.
732
void moveTo(double x, double y);
734
// Add a segment to the last subpath.
735
void lineTo(double x, double y);
737
// Add a Bezier curve to the last subpath
738
void curveTo(double x1, double y1, double x2, double y2,
739
double x3, double y3);
741
// Close the last subpath.
746
GBool justMoved; // set if a new subpath was just started
747
double firstX, firstY; // first point in new subpath
748
GfxSubpath **subpaths; // subpaths
749
int n; // number of subpaths
750
int size; // size of subpaths array
752
GfxPath(GBool justMoved1, double firstX1, double firstY1,
753
GfxSubpath **subpaths1, int n1, int size1);
756
//------------------------------------------------------------------------
758
//------------------------------------------------------------------------
763
// Construct a default GfxState, for a device with resolution <dpi>,
764
// page box <pageBox>, page rotation <rotate>, and coordinate system
765
// specified by <upsideDown>.
766
GfxState(double dpi, PDFRectangle *pageBox, int rotate,
773
GfxState *copy() const { return new GfxState(this); }
776
const double *getCTM() const { return ctm; }
777
double getX1() const { return px1; }
778
double getY1() const { return py1; }
779
double getX2() const { return px2; }
780
double getY2() const { return py2; }
781
double getPageWidth() const { return pageWidth; }
782
double getPageHeight() const { return pageHeight; }
783
const GfxColor *getFillColor() const { return &fillColor; }
784
const GfxColor *getStrokeColor() const { return &strokeColor; }
785
void getFillGray(double *gray) const
786
{ fillColorSpace->getGray(&fillColor, gray); }
787
void getStrokeGray(double *gray) const
788
{ strokeColorSpace->getGray(&fillColor, gray); }
789
void getFillRGB(GfxRGB *rgb) const
790
{ fillColorSpace->getRGB(&fillColor, rgb); }
791
void getStrokeRGB(GfxRGB *rgb) const
792
{ strokeColorSpace->getRGB(&strokeColor, rgb); }
793
void getFillCMYK(GfxCMYK *cmyk) const
794
{ fillColorSpace->getCMYK(&fillColor, cmyk); }
795
void getStrokeCMYK(GfxCMYK *cmyk) const
796
{ strokeColorSpace->getCMYK(&strokeColor, cmyk); }
797
GfxColorSpace *getFillColorSpace() const { return fillColorSpace; }
798
GfxColorSpace *getStrokeColorSpace() const { return strokeColorSpace; }
799
GfxPattern *getFillPattern() const { return fillPattern; }
800
GfxPattern *getStrokePattern() const { return strokePattern; }
801
double getFillOpacity() const { return fillOpacity; }
802
double getStrokeOpacity() const { return strokeOpacity; }
803
double getLineWidth() const { return lineWidth; }
804
void getLineDash(double **dash, int *length, double *start) const
805
{ *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
806
int getFlatness() const { return flatness; }
807
int getLineJoin() const { return lineJoin; }
808
int getLineCap() const { return lineCap; }
809
double getMiterLimit() const { return miterLimit; }
810
GfxFont *getFont() const { return font; }
811
double getFontSize() const { return fontSize; }
812
const double *getTextMat() const { return textMat; }
813
double getCharSpace() const { return charSpace; }
814
double getWordSpace() const { return wordSpace; }
815
double getHorizScaling() const { return horizScaling; }
816
double getLeading() const { return leading; }
817
double getRise() const { return rise; }
818
int getRender() const { return render; }
819
GfxPath *getPath() const { return path; }
820
double getCurX() const { return curX; }
821
double getCurY() const { return curY; }
822
void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const
823
{ *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
824
void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const;
825
double getLineX() const { return lineX; }
826
double getLineY() const { return lineY; }
828
// Is there a current point/path?
829
GBool isCurPt() const { return path->isCurPt(); }
830
GBool isPath() const { return path->isPath(); }
833
void transform(double x1, double y1, double *x2, double *y2)
834
{ *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
835
*y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
836
void transformDelta(double x1, double y1, double *x2, double *y2)
837
{ *x2 = ctm[0] * x1 + ctm[2] * y1;
838
*y2 = ctm[1] * x1 + ctm[3] * y1; }
839
void textTransform(double x1, double y1, double *x2, double *y2)
840
{ *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
841
*y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
842
void textTransformDelta(double x1, double y1, double *x2, double *y2)
843
{ *x2 = textMat[0] * x1 + textMat[2] * y1;
844
*y2 = textMat[1] * x1 + textMat[3] * y1; }
845
double transformWidth(double w);
846
double getTransformedLineWidth()
847
{ return transformWidth(lineWidth); }
848
double getTransformedFontSize();
849
void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
851
// Change state parameters.
852
void setCTM(double a, double b, double c,
853
double d, double e, double f);
854
void concatCTM(double a, double b, double c,
855
double d, double e, double f);
856
void setFillColorSpace(GfxColorSpace *colorSpace);
857
void setStrokeColorSpace(GfxColorSpace *colorSpace);
858
void setFillColor(GfxColor *color) { fillColor = *color; }
859
void setStrokeColor(GfxColor *color) { strokeColor = *color; }
860
void setFillPattern(GfxPattern *pattern);
861
void setStrokePattern(GfxPattern *pattern);
862
void setFillOpacity(double opac) { fillOpacity = opac; }
863
void setStrokeOpacity(double opac) { strokeOpacity = opac; }
864
void setLineWidth(double width) { lineWidth = width; }
865
void setLineDash(double *dash, int length, double start);
866
void setFlatness(int flatness1) { flatness = flatness1; }
867
void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
868
void setLineCap(int lineCap1) { lineCap = lineCap1; }
869
void setMiterLimit(double limit) { miterLimit = limit; }
870
void setFont(GfxFont *fontA, double fontSizeA)
871
{ font = fontA; fontSize = fontSizeA; }
872
void setTextMat(double a, double b, double c,
873
double d, double e, double f)
874
{ textMat[0] = a; textMat[1] = b; textMat[2] = c;
875
textMat[3] = d; textMat[4] = e; textMat[5] = f; }
876
void setCharSpace(double space)
877
{ charSpace = space; }
878
void setWordSpace(double space)
879
{ wordSpace = space; }
880
void setHorizScaling(double scale)
881
{ horizScaling = 0.01 * scale; }
882
void setLeading(double leadingA)
883
{ leading = leadingA; }
884
void setRise(double riseA)
886
void setRender(int renderA)
887
{ render = renderA; }
890
void moveTo(double x, double y)
891
{ path->moveTo(curX = x, curY = y); }
892
void lineTo(double x, double y)
893
{ path->lineTo(curX = x, curY = y); }
894
void curveTo(double x1, double y1, double x2, double y2,
895
double x3, double y3)
896
{ path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
898
{ path->close(); curX = path->getLastX(); curY = path->getLastY(); }
901
// Update clip region.
905
void textMoveTo(double tx, double ty)
906
{ lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
907
void textShift(double tx, double ty);
908
void shift(double dx, double dy);
910
// Push/pop GfxState on/off stack.
913
GBool hasSaves() { return saved != NULL; }
917
double ctm[6]; // coord transform matrix
918
double px1, py1, px2, py2; // page corners (user coords)
919
double pageWidth, pageHeight; // page size (pixels)
921
GfxColorSpace *fillColorSpace; // fill color space
922
GfxColorSpace *strokeColorSpace; // stroke color space
923
GfxColor fillColor; // fill color
924
GfxColor strokeColor; // stroke color
925
GfxPattern *fillPattern; // fill pattern
926
GfxPattern *strokePattern; // stroke pattern
927
double fillOpacity; // fill opacity
928
double strokeOpacity; // stroke opacity
930
double lineWidth; // line width
931
double *lineDash; // line dash
933
double lineDashStart;
934
int flatness; // curve flatness
935
int lineJoin; // line join style
936
int lineCap; // line cap style
937
double miterLimit; // line miter limit
939
GfxFont *font; // font
940
double fontSize; // font size
941
double textMat[6]; // text matrix
942
double charSpace; // character spacing
943
double wordSpace; // word spacing
944
double horizScaling; // horizontal scaling
945
double leading; // text leading
946
double rise; // text rise
947
int render; // text rendering mode
949
GfxPath *path; // array of path elements
950
double curX, curY; // current point (user coords)
951
double lineX, lineY; // start of current text line (text coords)
953
double clipXMin, clipYMin, // bounding box for clip region
956
GfxState *saved; // next GfxState on stack
958
GfxState(const GfxState *state);