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() = 0;
76 virtual GfxColorSpaceMode getMode() = 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(GfxColor *color, double *gray) = 0;
83 virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
84 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
86 // Return the number of color components.
87 virtual int getNComps() = 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,
97 //------------------------------------------------------------------------
98 // GfxDeviceGrayColorSpace
99 //------------------------------------------------------------------------
101 class GfxDeviceGrayColorSpace: public GfxColorSpace {
104 GfxDeviceGrayColorSpace();
105 virtual ~GfxDeviceGrayColorSpace();
106 virtual GfxColorSpace *copy();
107 virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
109 virtual void getGray(GfxColor *color, double *gray);
110 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
111 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
113 virtual int getNComps() { return 1; }
118 //------------------------------------------------------------------------
119 // GfxCalGrayColorSpace
120 //------------------------------------------------------------------------
122 class GfxCalGrayColorSpace: public GfxColorSpace {
125 GfxCalGrayColorSpace();
126 virtual ~GfxCalGrayColorSpace();
127 virtual GfxColorSpace *copy();
128 virtual GfxColorSpaceMode getMode() { return csCalGray; }
130 // Construct a CalGray color space. Returns NULL if unsuccessful.
131 static GfxColorSpace *parse(Array *arr);
133 virtual void getGray(GfxColor *color, double *gray);
134 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
135 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
137 virtual int getNComps() { return 1; }
139 // CalGray-specific access.
140 double getWhiteX() { return whiteX; }
141 double getWhiteY() { return whiteY; }
142 double getWhiteZ() { return whiteZ; }
143 double getBlackX() { return blackX; }
144 double getBlackY() { return blackY; }
145 double getBlackZ() { return blackZ; }
146 double getGamma() { 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();
165 virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
167 virtual void getGray(GfxColor *color, double *gray);
168 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
169 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
171 virtual int getNComps() { return 3; }
176 //------------------------------------------------------------------------
177 // GfxCalRGBColorSpace
178 //------------------------------------------------------------------------
180 class GfxCalRGBColorSpace: public GfxColorSpace {
183 GfxCalRGBColorSpace();
184 virtual ~GfxCalRGBColorSpace();
185 virtual GfxColorSpace *copy();
186 virtual GfxColorSpaceMode getMode() { return csCalRGB; }
188 // Construct a CalRGB color space. Returns NULL if unsuccessful.
189 static GfxColorSpace *parse(Array *arr);
191 virtual void getGray(GfxColor *color, double *gray);
192 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
193 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
195 virtual int getNComps() { return 3; }
197 // CalRGB-specific access.
198 double getWhiteX() { return whiteX; }
199 double getWhiteY() { return whiteY; }
200 double getWhiteZ() { return whiteZ; }
201 double getBlackX() { return blackX; }
202 double getBlackY() { return blackY; }
203 double getBlackZ() { return blackZ; }
204 double getGammaR() { return gammaR; }
205 double getGammaG() { return gammaG; }
206 double getGammaB() { return gammaB; }
207 double *getMatrix() { 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();
227 virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
229 virtual void getGray(GfxColor *color, double *gray);
230 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
231 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
233 virtual int getNComps() { return 4; }
238 //------------------------------------------------------------------------
240 //------------------------------------------------------------------------
242 class GfxLabColorSpace: public GfxColorSpace {
246 virtual ~GfxLabColorSpace();
247 virtual GfxColorSpace *copy();
248 virtual GfxColorSpaceMode getMode() { return csLab; }
250 // Construct a Lab color space. Returns NULL if unsuccessful.
251 static GfxColorSpace *parse(Array *arr);
253 virtual void getGray(GfxColor *color, double *gray);
254 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
255 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
257 virtual int getNComps() { return 3; }
259 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
262 // Lab-specific access.
263 double getWhiteX() { return whiteX; }
264 double getWhiteY() { return whiteY; }
265 double getWhiteZ() { return whiteZ; }
266 double getBlackX() { return blackX; }
267 double getBlackY() { return blackY; }
268 double getBlackZ() { return blackZ; }
269 double getAMin() { return aMin; }
270 double getAMax() { return aMax; }
271 double getBMin() { return bMin; }
272 double getBMax() { 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 Ref *iccProfileStreamA);
291 virtual ~GfxICCBasedColorSpace();
292 virtual GfxColorSpace *copy();
293 virtual GfxColorSpaceMode getMode() { return csICCBased; }
295 // Construct an ICCBased color space. Returns NULL if unsuccessful.
296 static GfxColorSpace *parse(Array *arr);
298 virtual void getGray(GfxColor *color, double *gray);
299 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
300 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
302 virtual int getNComps() { return nComps; }
304 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
307 // ICCBased-specific access.
308 GfxColorSpace *getAlt() { 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();
329 virtual GfxColorSpaceMode getMode() { return csIndexed; }
331 // Construct a Lab color space. Returns NULL if unsuccessful.
332 static GfxColorSpace *parse(Array *arr);
334 virtual void getGray(GfxColor *color, double *gray);
335 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
336 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
338 virtual int getNComps() { return 1; }
340 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
343 // Indexed-specific access.
344 GfxColorSpace *getBase() { return base; }
345 int getIndexHigh() { return indexHigh; }
346 Guchar *getLookup() { 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();
366 virtual GfxColorSpaceMode getMode() { return csSeparation; }
368 // Construct a Separation color space. Returns NULL if unsuccessful.
369 static GfxColorSpace *parse(Array *arr);
371 virtual void getGray(GfxColor *color, double *gray);
372 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
373 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
375 virtual int getNComps() { return 1; }
377 // Separation-specific access.
378 GString *getName() { return name; }
379 GfxColorSpace *getAlt() { return alt; }
380 Function *getFunc() { 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();
399 virtual GfxColorSpaceMode getMode() { return csDeviceN; }
401 // Construct a DeviceN color space. Returns NULL if unsuccessful.
402 static GfxColorSpace *parse(Array *arr);
404 virtual void getGray(GfxColor *color, double *gray);
405 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
406 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
408 virtual int getNComps() { return nComps; }
410 // DeviceN-specific access.
411 GString *getColorantName(int i) { return names[i]; }
412 GfxColorSpace *getAlt() { return alt; }
413 Function *getTintTransformFunc() { 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();
435 virtual GfxColorSpaceMode getMode() { return csPattern; }
437 // Construct a Pattern color space. Returns NULL if unsuccessful.
438 static GfxColorSpace *parse(Array *arr);
440 virtual void getGray(GfxColor *color, double *gray);
441 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
442 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
444 virtual int getNComps() { return 0; }
446 // Pattern-specific access.
447 GfxColorSpace *getUnder() { 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 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() { return new GfxState(this); }
776 double *getCTM() { return ctm; }
777 double getX1() { return px1; }
778 double getY1() { return py1; }
779 double getX2() { return px2; }
780 double getY2() { return py2; }
781 double getPageWidth() { return pageWidth; }
782 double getPageHeight() { return pageHeight; }
783 GfxColor *getFillColor() { return &fillColor; }
784 GfxColor *getStrokeColor() { return &strokeColor; }
785 void getFillGray(double *gray)
786 { fillColorSpace->getGray(&fillColor, gray); }
787 void getStrokeGray(double *gray)
788 { strokeColorSpace->getGray(&fillColor, gray); }
789 void getFillRGB(GfxRGB *rgb)
790 { fillColorSpace->getRGB(&fillColor, rgb); }
791 void getStrokeRGB(GfxRGB *rgb)
792 { strokeColorSpace->getRGB(&strokeColor, rgb); }
793 void getFillCMYK(GfxCMYK *cmyk)
794 { fillColorSpace->getCMYK(&fillColor, cmyk); }
795 void getStrokeCMYK(GfxCMYK *cmyk)
796 { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
797 GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
798 GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
799 GfxPattern *getFillPattern() { return fillPattern; }
800 GfxPattern *getStrokePattern() { return strokePattern; }
801 double getFillOpacity() { return fillOpacity; }
802 double getStrokeOpacity() { return strokeOpacity; }
803 double getLineWidth() { return lineWidth; }
804 void getLineDash(double **dash, int *length, double *start)
805 { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
806 int getFlatness() { return flatness; }
807 int getLineJoin() { return lineJoin; }
808 int getLineCap() { return lineCap; }
809 double getMiterLimit() { return miterLimit; }
810 GfxFont *getFont() { return font; }
811 double getFontSize() { return fontSize; }
812 double *getTextMat() { return textMat; }
813 double getCharSpace() { return charSpace; }
814 double getWordSpace() { return wordSpace; }
815 double getHorizScaling() { return horizScaling; }
816 double getLeading() { return leading; }
817 double getRise() { return rise; }
818 int getRender() { return render; }
819 GfxPath *getPath() { return path; }
820 double getCurX() { return curX; }
821 double getCurY() { return curY; }
822 void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax)
823 { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
824 void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
825 double getLineX() { return lineX; }
826 double getLineY() { return lineY; }
828 // Is there a current point/path?
829 GBool isCurPt() { return path->isCurPt(); }
830 GBool isPath() { 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(GfxState *state);