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 // NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames
57 // array defined in GfxState.cc must match this enum.
58 enum GfxColorSpaceMode {
76 virtual ~GfxColorSpace();
77 virtual GfxColorSpace *copy() = 0;
78 virtual GfxColorSpaceMode getMode() = 0;
80 // Construct a color space. Returns NULL if unsuccessful.
81 static GfxColorSpace *parse(Object *csObj);
83 // Convert to gray, RGB, or CMYK.
84 virtual void getGray(GfxColor *color, double *gray) = 0;
85 virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
86 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
88 // Return the number of color components.
89 virtual int getNComps() = 0;
91 // Return the default ranges for each component, assuming an image
92 // with a max pixel value of <maxImgPixel>.
93 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
96 // Return the number of color space modes
97 static int getNumColorSpaceModes();
99 // Return the name of the <idx>th color space mode.
100 static char *getColorSpaceModeName(int idx);
105 //------------------------------------------------------------------------
106 // GfxDeviceGrayColorSpace
107 //------------------------------------------------------------------------
109 class GfxDeviceGrayColorSpace: public GfxColorSpace {
112 GfxDeviceGrayColorSpace();
113 virtual ~GfxDeviceGrayColorSpace();
114 virtual GfxColorSpace *copy();
115 virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
117 virtual void getGray(GfxColor *color, double *gray);
118 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
119 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
121 virtual int getNComps() { return 1; }
126 //------------------------------------------------------------------------
127 // GfxCalGrayColorSpace
128 //------------------------------------------------------------------------
130 class GfxCalGrayColorSpace: public GfxColorSpace {
133 GfxCalGrayColorSpace();
134 virtual ~GfxCalGrayColorSpace();
135 virtual GfxColorSpace *copy();
136 virtual GfxColorSpaceMode getMode() { return csCalGray; }
138 // Construct a CalGray color space. Returns NULL if unsuccessful.
139 static GfxColorSpace *parse(Array *arr);
141 virtual void getGray(GfxColor *color, double *gray);
142 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
143 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
145 virtual int getNComps() { return 1; }
147 // CalGray-specific access.
148 double getWhiteX() { return whiteX; }
149 double getWhiteY() { return whiteY; }
150 double getWhiteZ() { return whiteZ; }
151 double getBlackX() { return blackX; }
152 double getBlackY() { return blackY; }
153 double getBlackZ() { return blackZ; }
154 double getGamma() { return gamma; }
158 double whiteX, whiteY, whiteZ; // white point
159 double blackX, blackY, blackZ; // black point
160 double gamma; // gamma value
163 //------------------------------------------------------------------------
164 // GfxDeviceRGBColorSpace
165 //------------------------------------------------------------------------
167 class GfxDeviceRGBColorSpace: public GfxColorSpace {
170 GfxDeviceRGBColorSpace();
171 virtual ~GfxDeviceRGBColorSpace();
172 virtual GfxColorSpace *copy();
173 virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
175 virtual void getGray(GfxColor *color, double *gray);
176 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
177 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
179 virtual int getNComps() { return 3; }
184 //------------------------------------------------------------------------
185 // GfxCalRGBColorSpace
186 //------------------------------------------------------------------------
188 class GfxCalRGBColorSpace: public GfxColorSpace {
191 GfxCalRGBColorSpace();
192 virtual ~GfxCalRGBColorSpace();
193 virtual GfxColorSpace *copy();
194 virtual GfxColorSpaceMode getMode() { return csCalRGB; }
196 // Construct a CalRGB color space. Returns NULL if unsuccessful.
197 static GfxColorSpace *parse(Array *arr);
199 virtual void getGray(GfxColor *color, double *gray);
200 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
201 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
203 virtual int getNComps() { return 3; }
205 // CalRGB-specific access.
206 double getWhiteX() { return whiteX; }
207 double getWhiteY() { return whiteY; }
208 double getWhiteZ() { return whiteZ; }
209 double getBlackX() { return blackX; }
210 double getBlackY() { return blackY; }
211 double getBlackZ() { return blackZ; }
212 double getGammaR() { return gammaR; }
213 double getGammaG() { return gammaG; }
214 double getGammaB() { return gammaB; }
215 double *getMatrix() { return mat; }
219 double whiteX, whiteY, whiteZ; // white point
220 double blackX, blackY, blackZ; // black point
221 double gammaR, gammaG, gammaB; // gamma values
222 double mat[9]; // ABC -> XYZ transform matrix
225 //------------------------------------------------------------------------
226 // GfxDeviceCMYKColorSpace
227 //------------------------------------------------------------------------
229 class GfxDeviceCMYKColorSpace: public GfxColorSpace {
232 GfxDeviceCMYKColorSpace();
233 virtual ~GfxDeviceCMYKColorSpace();
234 virtual GfxColorSpace *copy();
235 virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
237 virtual void getGray(GfxColor *color, double *gray);
238 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
239 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
241 virtual int getNComps() { return 4; }
246 //------------------------------------------------------------------------
248 //------------------------------------------------------------------------
250 class GfxLabColorSpace: public GfxColorSpace {
254 virtual ~GfxLabColorSpace();
255 virtual GfxColorSpace *copy();
256 virtual GfxColorSpaceMode getMode() { return csLab; }
258 // Construct a Lab color space. Returns NULL if unsuccessful.
259 static GfxColorSpace *parse(Array *arr);
261 virtual void getGray(GfxColor *color, double *gray);
262 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
263 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
265 virtual int getNComps() { return 3; }
267 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
270 // Lab-specific access.
271 double getWhiteX() { return whiteX; }
272 double getWhiteY() { return whiteY; }
273 double getWhiteZ() { return whiteZ; }
274 double getBlackX() { return blackX; }
275 double getBlackY() { return blackY; }
276 double getBlackZ() { return blackZ; }
277 double getAMin() { return aMin; }
278 double getAMax() { return aMax; }
279 double getBMin() { return bMin; }
280 double getBMax() { return bMax; }
284 double whiteX, whiteY, whiteZ; // white point
285 double blackX, blackY, blackZ; // black point
286 double aMin, aMax, bMin, bMax; // range for the a and b components
287 double kr, kg, kb; // gamut mapping mulitpliers
290 //------------------------------------------------------------------------
291 // GfxICCBasedColorSpace
292 //------------------------------------------------------------------------
294 class GfxICCBasedColorSpace: public GfxColorSpace {
297 GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
298 Ref *iccProfileStreamA);
299 virtual ~GfxICCBasedColorSpace();
300 virtual GfxColorSpace *copy();
301 virtual GfxColorSpaceMode getMode() { return csICCBased; }
303 // Construct an ICCBased color space. Returns NULL if unsuccessful.
304 static GfxColorSpace *parse(Array *arr);
306 virtual void getGray(GfxColor *color, double *gray);
307 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
308 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
310 virtual int getNComps() { return nComps; }
312 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
315 // ICCBased-specific access.
316 GfxColorSpace *getAlt() { return alt; }
320 int nComps; // number of color components (1, 3, or 4)
321 GfxColorSpace *alt; // alternate color space
322 double rangeMin[4]; // min values for each component
323 double rangeMax[4]; // max values for each component
324 Ref iccProfileStream; // the ICC profile
327 //------------------------------------------------------------------------
328 // GfxIndexedColorSpace
329 //------------------------------------------------------------------------
331 class GfxIndexedColorSpace: public GfxColorSpace {
334 GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
335 virtual ~GfxIndexedColorSpace();
336 virtual GfxColorSpace *copy();
337 virtual GfxColorSpaceMode getMode() { return csIndexed; }
339 // Construct a Lab color space. Returns NULL if unsuccessful.
340 static GfxColorSpace *parse(Array *arr);
342 virtual void getGray(GfxColor *color, double *gray);
343 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
344 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
346 virtual int getNComps() { return 1; }
348 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
351 // Indexed-specific access.
352 GfxColorSpace *getBase() { return base; }
353 int getIndexHigh() { return indexHigh; }
354 Guchar *getLookup() { return lookup; }
355 GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor);
359 GfxColorSpace *base; // base color space
360 int indexHigh; // max pixel value
361 Guchar *lookup; // lookup table
364 //------------------------------------------------------------------------
365 // GfxSeparationColorSpace
366 //------------------------------------------------------------------------
368 class GfxSeparationColorSpace: public GfxColorSpace {
371 GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
373 virtual ~GfxSeparationColorSpace();
374 virtual GfxColorSpace *copy();
375 virtual GfxColorSpaceMode getMode() { return csSeparation; }
377 // Construct a Separation color space. Returns NULL if unsuccessful.
378 static GfxColorSpace *parse(Array *arr);
380 virtual void getGray(GfxColor *color, double *gray);
381 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
382 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
384 virtual int getNComps() { return 1; }
386 // Separation-specific access.
387 GString *getName() { return name; }
388 GfxColorSpace *getAlt() { return alt; }
389 Function *getFunc() { return func; }
393 GString *name; // colorant name
394 GfxColorSpace *alt; // alternate color space
395 Function *func; // tint transform (into alternate color space)
398 //------------------------------------------------------------------------
399 // GfxDeviceNColorSpace
400 //------------------------------------------------------------------------
402 class GfxDeviceNColorSpace: public GfxColorSpace {
405 GfxDeviceNColorSpace(int nComps, GfxColorSpace *alt, Function *func);
406 virtual ~GfxDeviceNColorSpace();
407 virtual GfxColorSpace *copy();
408 virtual GfxColorSpaceMode getMode() { return csDeviceN; }
410 // Construct a DeviceN color space. Returns NULL if unsuccessful.
411 static GfxColorSpace *parse(Array *arr);
413 virtual void getGray(GfxColor *color, double *gray);
414 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
415 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
417 virtual int getNComps() { return nComps; }
419 // DeviceN-specific access.
420 GString *getColorantName(int i) { return names[i]; }
421 GfxColorSpace *getAlt() { return alt; }
422 Function *getTintTransformFunc() { return func; }
426 int nComps; // number of components
427 GString // colorant names
428 *names[gfxColorMaxComps];
429 GfxColorSpace *alt; // alternate color space
430 Function *func; // tint transform (into alternate color space)
434 //------------------------------------------------------------------------
435 // GfxPatternColorSpace
436 //------------------------------------------------------------------------
438 class GfxPatternColorSpace: public GfxColorSpace {
441 GfxPatternColorSpace(GfxColorSpace *underA);
442 virtual ~GfxPatternColorSpace();
443 virtual GfxColorSpace *copy();
444 virtual GfxColorSpaceMode getMode() { return csPattern; }
446 // Construct a Pattern color space. Returns NULL if unsuccessful.
447 static GfxColorSpace *parse(Array *arr);
449 virtual void getGray(GfxColor *color, double *gray);
450 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
451 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
453 virtual int getNComps() { return 0; }
455 // Pattern-specific access.
456 GfxColorSpace *getUnder() { return under; }
460 GfxColorSpace *under; // underlying color space (for uncolored
464 //------------------------------------------------------------------------
466 //------------------------------------------------------------------------
471 GfxPattern(int typeA);
472 virtual ~GfxPattern();
474 static GfxPattern *parse(Object *obj);
476 virtual GfxPattern *copy() = 0;
478 int getType() { return type; }
485 //------------------------------------------------------------------------
487 //------------------------------------------------------------------------
489 class GfxTilingPattern: public GfxPattern {
492 GfxTilingPattern(Dict *streamDict, Object *stream);
493 virtual ~GfxTilingPattern();
495 virtual GfxPattern *copy();
497 int getPaintType() { return paintType; }
498 int getTilingType() { return tilingType; }
499 double *getBBox() { return bbox; }
500 double getXStep() { return xStep; }
501 double getYStep() { return yStep; }
503 { return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
504 double *getMatrix() { return matrix; }
505 Object *getContentStream() { return &contentStream; }
509 GfxTilingPattern(GfxTilingPattern *pat);
517 Object contentStream;
520 //------------------------------------------------------------------------
522 //------------------------------------------------------------------------
528 virtual ~GfxShading();
530 static GfxShading *parse(Object *obj);
532 int getType() { return type; }
533 GfxColorSpace *getColorSpace() { return colorSpace; }
534 GfxColor *getBackground() { return &background; }
535 GBool getHasBackground() { return hasBackground; }
536 void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
537 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
538 GBool getHasBBox() { return hasBBox; }
543 GfxColorSpace *colorSpace;
546 double xMin, yMin, xMax, yMax;
550 //------------------------------------------------------------------------
552 //------------------------------------------------------------------------
554 class GfxAxialShading: public GfxShading {
557 GfxAxialShading(double x0A, double y0A,
558 double x1A, double y1A,
559 double t0A, double t1A,
560 Function **funcsA, int nFuncsA,
561 GBool extend0A, GBool extend1A);
562 virtual ~GfxAxialShading();
564 static GfxAxialShading *parse(Dict *dict);
566 void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
567 { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
568 double getDomain0() { return t0; }
569 double getDomain1() { return t1; }
570 void getColor(double t, GfxColor *color);
571 GBool getExtend0() { return extend0; }
572 GBool getExtend1() { return extend1; }
576 double x0, y0, x1, y1;
578 Function *funcs[gfxColorMaxComps];
580 GBool extend0, extend1;
583 //------------------------------------------------------------------------
585 //------------------------------------------------------------------------
587 class GfxRadialShading: public GfxShading {
590 GfxRadialShading(double x0A, double y0A, double r0A,
591 double x1A, double y1A, double r1A,
592 double t0A, double t1A,
593 Function **funcsA, int nFuncsA,
594 GBool extend0A, GBool extend1A);
595 virtual ~GfxRadialShading();
597 static GfxRadialShading *parse(Dict *dict);
599 void getCoords(double *x0A, double *y0A, double *r0A,
600 double *x1A, double *y1A, double *r1A)
601 { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
602 double getDomain0() { return t0; }
603 double getDomain1() { return t1; }
604 void getColor(double t, GfxColor *color);
605 GBool getExtend0() { return extend0; }
606 GBool getExtend1() { return extend1; }
610 double x0, y0, r0, x1, y1, r1;
612 Function *funcs[gfxColorMaxComps];
614 GBool extend0, extend1;
617 //------------------------------------------------------------------------
619 //------------------------------------------------------------------------
621 class GfxImageColorMap {
625 GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
630 // Is color map valid?
631 GBool isOk() { return ok; }
633 // Get the color space.
634 GfxColorSpace *getColorSpace() { return colorSpace; }
636 // Get stream decoding info.
637 int getNumPixelComps() { return nComps; }
638 int getBits() { return bits; }
641 double getDecodeLow(int i) { return decodeLow[i]; }
642 double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
644 // Convert an image pixel to a color.
645 void getGray(Guchar *x, double *gray);
646 void getRGB(Guchar *x, GfxRGB *rgb);
647 void getCMYK(Guchar *x, GfxCMYK *cmyk);
648 void getColor(Guchar *x, GfxColor *color);
652 GfxColorSpace *colorSpace; // the image color space
653 int bits; // bits per component
654 int nComps; // number of components in a pixel
655 GfxColorSpace *colorSpace2; // secondary color space
656 int nComps2; // number of components in colorSpace2
657 double *lookup; // lookup table
658 double // minimum values for each component
659 decodeLow[gfxColorMaxComps];
660 double // max - min value for each component
661 decodeRange[gfxColorMaxComps];
665 //------------------------------------------------------------------------
666 // GfxSubpath and GfxPath
667 //------------------------------------------------------------------------
673 GfxSubpath(double x1, double y1);
679 GfxSubpath *copy() { return new GfxSubpath(this); }
682 int getNumPoints() { return n; }
683 double getX(int i) { return x[i]; }
684 double getY(int i) { return y[i]; }
685 GBool getCurve(int i) { return curve[i]; }
688 double getLastX() { return x[n-1]; }
689 double getLastY() { return y[n-1]; }
691 // Add a line segment.
692 void lineTo(double x1, double y1);
694 // Add a Bezier curve.
695 void curveTo(double x1, double y1, double x2, double y2,
696 double x3, double y3);
698 // Close the subpath.
700 GBool isClosed() { return closed; }
704 double *x, *y; // points
705 GBool *curve; // curve[i] => point i is a control point
706 // for a Bezier curve
707 int n; // number of points
708 int size; // size of x/y arrays
709 GBool closed; // set if path is closed
711 GfxSubpath(GfxSubpath *subpath);
725 { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
727 // Is there a current point?
728 GBool isCurPt() { return n > 0 || justMoved; }
730 // Is the path non-empty, i.e., is there at least one segment?
731 GBool isPath() { return n > 0; }
734 int getNumSubpaths() { return n; }
735 GfxSubpath *getSubpath(int i) { return subpaths[i]; }
737 // Get last point on last subpath.
738 double getLastX() { return subpaths[n-1]->getLastX(); }
739 double getLastY() { return subpaths[n-1]->getLastY(); }
741 // Move the current point.
742 void moveTo(double x, double y);
744 // Add a segment to the last subpath.
745 void lineTo(double x, double y);
747 // Add a Bezier curve to the last subpath
748 void curveTo(double x1, double y1, double x2, double y2,
749 double x3, double y3);
751 // Close the last subpath.
756 GBool justMoved; // set if a new subpath was just started
757 double firstX, firstY; // first point in new subpath
758 GfxSubpath **subpaths; // subpaths
759 int n; // number of subpaths
760 int size; // size of subpaths array
762 GfxPath(GBool justMoved1, double firstX1, double firstY1,
763 GfxSubpath **subpaths1, int n1, int size1);
766 //------------------------------------------------------------------------
768 //------------------------------------------------------------------------
773 // Construct a default GfxState, for a device with resolution <dpi>,
774 // page box <pageBox>, page rotation <rotate>, and coordinate system
775 // specified by <upsideDown>.
776 GfxState(double dpi, PDFRectangle *pageBox, int rotate,
783 GfxState *copy() { return new GfxState(this); }
786 double *getCTM() { return ctm; }
787 double getX1() { return px1; }
788 double getY1() { return py1; }
789 double getX2() { return px2; }
790 double getY2() { return py2; }
791 double getPageWidth() { return pageWidth; }
792 double getPageHeight() { return pageHeight; }
793 GfxColor *getFillColor() { return &fillColor; }
794 GfxColor *getStrokeColor() { return &strokeColor; }
795 void getFillGray(double *gray)
796 { fillColorSpace->getGray(&fillColor, gray); }
797 void getStrokeGray(double *gray)
798 { strokeColorSpace->getGray(&fillColor, gray); }
799 void getFillRGB(GfxRGB *rgb)
800 { fillColorSpace->getRGB(&fillColor, rgb); }
801 void getStrokeRGB(GfxRGB *rgb)
802 { strokeColorSpace->getRGB(&strokeColor, rgb); }
803 void getFillCMYK(GfxCMYK *cmyk)
804 { fillColorSpace->getCMYK(&fillColor, cmyk); }
805 void getStrokeCMYK(GfxCMYK *cmyk)
806 { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
807 GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
808 GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
809 GfxPattern *getFillPattern() { return fillPattern; }
810 GfxPattern *getStrokePattern() { return strokePattern; }
811 double getFillOpacity() { return fillOpacity; }
812 double getStrokeOpacity() { return strokeOpacity; }
813 double getLineWidth() { return lineWidth; }
814 void getLineDash(double **dash, int *length, double *start)
815 { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
816 int getFlatness() { return flatness; }
817 int getLineJoin() { return lineJoin; }
818 int getLineCap() { return lineCap; }
819 double getMiterLimit() { return miterLimit; }
820 GfxFont *getFont() { return font; }
821 double getFontSize() { return fontSize; }
822 double *getTextMat() { return textMat; }
823 double getCharSpace() { return charSpace; }
824 double getWordSpace() { return wordSpace; }
825 double getHorizScaling() { return horizScaling; }
826 double getLeading() { return leading; }
827 double getRise() { return rise; }
828 int getRender() { return render; }
829 GfxPath *getPath() { return path; }
830 double getCurX() { return curX; }
831 double getCurY() { return curY; }
832 void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax)
833 { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
834 void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
835 double getLineX() { return lineX; }
836 double getLineY() { return lineY; }
838 // Is there a current point/path?
839 GBool isCurPt() { return path->isCurPt(); }
840 GBool isPath() { return path->isPath(); }
843 void transform(double x1, double y1, double *x2, double *y2)
844 { *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
845 *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
846 void transformDelta(double x1, double y1, double *x2, double *y2)
847 { *x2 = ctm[0] * x1 + ctm[2] * y1;
848 *y2 = ctm[1] * x1 + ctm[3] * y1; }
849 void textTransform(double x1, double y1, double *x2, double *y2)
850 { *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
851 *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
852 void textTransformDelta(double x1, double y1, double *x2, double *y2)
853 { *x2 = textMat[0] * x1 + textMat[2] * y1;
854 *y2 = textMat[1] * x1 + textMat[3] * y1; }
855 double transformWidth(double w);
856 double getTransformedLineWidth()
857 { return transformWidth(lineWidth); }
858 double getTransformedFontSize();
859 void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
861 // Change state parameters.
862 void setCTM(double a, double b, double c,
863 double d, double e, double f);
864 void concatCTM(double a, double b, double c,
865 double d, double e, double f);
866 void setFillColorSpace(GfxColorSpace *colorSpace);
867 void setStrokeColorSpace(GfxColorSpace *colorSpace);
868 void setFillColor(GfxColor *color) { fillColor = *color; }
869 void setStrokeColor(GfxColor *color) { strokeColor = *color; }
870 void setFillPattern(GfxPattern *pattern);
871 void setStrokePattern(GfxPattern *pattern);
872 void setFillOpacity(double opac) { fillOpacity = opac; }
873 void setStrokeOpacity(double opac) { strokeOpacity = opac; }
874 void setLineWidth(double width) { lineWidth = width; }
875 void setLineDash(double *dash, int length, double start);
876 void setFlatness(int flatness1) { flatness = flatness1; }
877 void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
878 void setLineCap(int lineCap1) { lineCap = lineCap1; }
879 void setMiterLimit(double limit) { miterLimit = limit; }
880 void setFont(GfxFont *fontA, double fontSizeA)
881 { font = fontA; fontSize = fontSizeA; }
882 void setTextMat(double a, double b, double c,
883 double d, double e, double f)
884 { textMat[0] = a; textMat[1] = b; textMat[2] = c;
885 textMat[3] = d; textMat[4] = e; textMat[5] = f; }
886 void setCharSpace(double space)
887 { charSpace = space; }
888 void setWordSpace(double space)
889 { wordSpace = space; }
890 void setHorizScaling(double scale)
891 { horizScaling = 0.01 * scale; }
892 void setLeading(double leadingA)
893 { leading = leadingA; }
894 void setRise(double riseA)
896 void setRender(int renderA)
897 { render = renderA; }
900 void moveTo(double x, double y)
901 { path->moveTo(curX = x, curY = y); }
902 void lineTo(double x, double y)
903 { path->lineTo(curX = x, curY = y); }
904 void curveTo(double x1, double y1, double x2, double y2,
905 double x3, double y3)
906 { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
908 { path->close(); curX = path->getLastX(); curY = path->getLastY(); }
911 // Update clip region.
915 void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; }
916 void textMoveTo(double tx, double ty)
917 { lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
918 void textShift(double tx, double ty);
919 void shift(double dx, double dy);
921 // Push/pop GfxState on/off stack.
924 GBool hasSaves() { return saved != NULL; }
928 double ctm[6]; // coord transform matrix
929 double px1, py1, px2, py2; // page corners (user coords)
930 double pageWidth, pageHeight; // page size (pixels)
932 GfxColorSpace *fillColorSpace; // fill color space
933 GfxColorSpace *strokeColorSpace; // stroke color space
934 GfxColor fillColor; // fill color
935 GfxColor strokeColor; // stroke color
936 GfxPattern *fillPattern; // fill pattern
937 GfxPattern *strokePattern; // stroke pattern
938 double fillOpacity; // fill opacity
939 double strokeOpacity; // stroke opacity
941 double lineWidth; // line width
942 double *lineDash; // line dash
944 double lineDashStart;
945 int flatness; // curve flatness
946 int lineJoin; // line join style
947 int lineCap; // line cap style
948 double miterLimit; // line miter limit
950 GfxFont *font; // font
951 double fontSize; // font size
952 double textMat[6]; // text matrix
953 double charSpace; // character spacing
954 double wordSpace; // word spacing
955 double horizScaling; // horizontal scaling
956 double leading; // text leading
957 double rise; // text rise
958 int render; // text rendering mode
960 GfxPath *path; // array of path elements
961 double curX, curY; // current point (user coords)
962 double lineX, lineY; // start of current text line (text coords)
964 double clipXMin, clipYMin, // bounding box for clip region
967 GfxState *saved; // next GfxState on stack
969 GfxState(GfxState *state);