1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
27 //------------------------------------------------------------------------
29 //------------------------------------------------------------------------
31 #define gfxColorMaxComps funcMaxOutputs
34 double c[gfxColorMaxComps];
37 //------------------------------------------------------------------------
39 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
47 //------------------------------------------------------------------------
53 //------------------------------------------------------------------------
55 //------------------------------------------------------------------------
57 // NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames
58 // array defined in GfxState.cc must match this enum.
59 enum GfxColorSpaceMode {
77 virtual ~GfxColorSpace();
78 virtual GfxColorSpace *copy() = 0;
79 virtual GfxColorSpaceMode getMode() = 0;
81 // Construct a color space. Returns NULL if unsuccessful.
82 static GfxColorSpace *parse(Object *csObj);
84 // Convert to gray, RGB, or CMYK.
85 virtual void getGray(GfxColor *color, double *gray) = 0;
86 virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
87 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
89 // Return the number of color components.
90 virtual int getNComps() = 0;
92 // Return the default ranges for each component, assuming an image
93 // with a max pixel value of <maxImgPixel>.
94 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
97 // Return the number of color space modes
98 static int getNumColorSpaceModes();
100 // Return the name of the <idx>th color space mode.
101 static char *getColorSpaceModeName(int idx);
106 //------------------------------------------------------------------------
107 // GfxDeviceGrayColorSpace
108 //------------------------------------------------------------------------
110 class GfxDeviceGrayColorSpace: public GfxColorSpace {
113 GfxDeviceGrayColorSpace();
114 virtual ~GfxDeviceGrayColorSpace();
115 virtual GfxColorSpace *copy();
116 virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
118 virtual void getGray(GfxColor *color, double *gray);
119 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
120 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
122 virtual int getNComps() { return 1; }
127 //------------------------------------------------------------------------
128 // GfxCalGrayColorSpace
129 //------------------------------------------------------------------------
131 class GfxCalGrayColorSpace: public GfxColorSpace {
134 GfxCalGrayColorSpace();
135 virtual ~GfxCalGrayColorSpace();
136 virtual GfxColorSpace *copy();
137 virtual GfxColorSpaceMode getMode() { return csCalGray; }
139 // Construct a CalGray color space. Returns NULL if unsuccessful.
140 static GfxColorSpace *parse(Array *arr);
142 virtual void getGray(GfxColor *color, double *gray);
143 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
144 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
146 virtual int getNComps() { return 1; }
148 // CalGray-specific access.
149 double getWhiteX() { return whiteX; }
150 double getWhiteY() { return whiteY; }
151 double getWhiteZ() { return whiteZ; }
152 double getBlackX() { return blackX; }
153 double getBlackY() { return blackY; }
154 double getBlackZ() { return blackZ; }
155 double getGamma() { return gamma; }
159 double whiteX, whiteY, whiteZ; // white point
160 double blackX, blackY, blackZ; // black point
161 double gamma; // gamma value
164 //------------------------------------------------------------------------
165 // GfxDeviceRGBColorSpace
166 //------------------------------------------------------------------------
168 class GfxDeviceRGBColorSpace: public GfxColorSpace {
171 GfxDeviceRGBColorSpace();
172 virtual ~GfxDeviceRGBColorSpace();
173 virtual GfxColorSpace *copy();
174 virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
176 virtual void getGray(GfxColor *color, double *gray);
177 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
178 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
180 virtual int getNComps() { return 3; }
185 //------------------------------------------------------------------------
186 // GfxCalRGBColorSpace
187 //------------------------------------------------------------------------
189 class GfxCalRGBColorSpace: public GfxColorSpace {
192 GfxCalRGBColorSpace();
193 virtual ~GfxCalRGBColorSpace();
194 virtual GfxColorSpace *copy();
195 virtual GfxColorSpaceMode getMode() { return csCalRGB; }
197 // Construct a CalRGB color space. Returns NULL if unsuccessful.
198 static GfxColorSpace *parse(Array *arr);
200 virtual void getGray(GfxColor *color, double *gray);
201 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
202 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
204 virtual int getNComps() { return 3; }
206 // CalRGB-specific access.
207 double getWhiteX() { return whiteX; }
208 double getWhiteY() { return whiteY; }
209 double getWhiteZ() { return whiteZ; }
210 double getBlackX() { return blackX; }
211 double getBlackY() { return blackY; }
212 double getBlackZ() { return blackZ; }
213 double getGammaR() { return gammaR; }
214 double getGammaG() { return gammaG; }
215 double getGammaB() { return gammaB; }
216 double *getMatrix() { return mat; }
220 double whiteX, whiteY, whiteZ; // white point
221 double blackX, blackY, blackZ; // black point
222 double gammaR, gammaG, gammaB; // gamma values
223 double mat[9]; // ABC -> XYZ transform matrix
226 //------------------------------------------------------------------------
227 // GfxDeviceCMYKColorSpace
228 //------------------------------------------------------------------------
230 class GfxDeviceCMYKColorSpace: public GfxColorSpace {
233 GfxDeviceCMYKColorSpace();
234 virtual ~GfxDeviceCMYKColorSpace();
235 virtual GfxColorSpace *copy();
236 virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
238 virtual void getGray(GfxColor *color, double *gray);
239 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
240 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
242 virtual int getNComps() { return 4; }
247 //------------------------------------------------------------------------
249 //------------------------------------------------------------------------
251 class GfxLabColorSpace: public GfxColorSpace {
255 virtual ~GfxLabColorSpace();
256 virtual GfxColorSpace *copy();
257 virtual GfxColorSpaceMode getMode() { return csLab; }
259 // Construct a Lab color space. Returns NULL if unsuccessful.
260 static GfxColorSpace *parse(Array *arr);
262 virtual void getGray(GfxColor *color, double *gray);
263 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
264 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
266 virtual int getNComps() { return 3; }
268 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
271 // Lab-specific access.
272 double getWhiteX() { return whiteX; }
273 double getWhiteY() { return whiteY; }
274 double getWhiteZ() { return whiteZ; }
275 double getBlackX() { return blackX; }
276 double getBlackY() { return blackY; }
277 double getBlackZ() { return blackZ; }
278 double getAMin() { return aMin; }
279 double getAMax() { return aMax; }
280 double getBMin() { return bMin; }
281 double getBMax() { return bMax; }
285 double whiteX, whiteY, whiteZ; // white point
286 double blackX, blackY, blackZ; // black point
287 double aMin, aMax, bMin, bMax; // range for the a and b components
288 double kr, kg, kb; // gamut mapping mulitpliers
291 //------------------------------------------------------------------------
292 // GfxICCBasedColorSpace
293 //------------------------------------------------------------------------
295 class GfxICCBasedColorSpace: public GfxColorSpace {
298 GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
299 Ref *iccProfileStreamA);
300 virtual ~GfxICCBasedColorSpace();
301 virtual GfxColorSpace *copy();
302 virtual GfxColorSpaceMode getMode() { return csICCBased; }
304 // Construct an ICCBased color space. Returns NULL if unsuccessful.
305 static GfxColorSpace *parse(Array *arr);
307 virtual void getGray(GfxColor *color, double *gray);
308 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
309 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
311 virtual int getNComps() { return nComps; }
313 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
316 // ICCBased-specific access.
317 GfxColorSpace *getAlt() { return alt; }
321 int nComps; // number of color components (1, 3, or 4)
322 GfxColorSpace *alt; // alternate color space
323 double rangeMin[4]; // min values for each component
324 double rangeMax[4]; // max values for each component
325 Ref iccProfileStream; // the ICC profile
328 //------------------------------------------------------------------------
329 // GfxIndexedColorSpace
330 //------------------------------------------------------------------------
332 class GfxIndexedColorSpace: public GfxColorSpace {
335 GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
336 virtual ~GfxIndexedColorSpace();
337 virtual GfxColorSpace *copy();
338 virtual GfxColorSpaceMode getMode() { return csIndexed; }
340 // Construct a Lab color space. Returns NULL if unsuccessful.
341 static GfxColorSpace *parse(Array *arr);
343 virtual void getGray(GfxColor *color, double *gray);
344 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
345 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
347 virtual int getNComps() { return 1; }
349 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
352 // Indexed-specific access.
353 GfxColorSpace *getBase() { return base; }
354 int getIndexHigh() { return indexHigh; }
355 Guchar *getLookup() { return lookup; }
356 GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor);
360 GfxColorSpace *base; // base color space
361 int indexHigh; // max pixel value
362 Guchar *lookup; // lookup table
365 //------------------------------------------------------------------------
366 // GfxSeparationColorSpace
367 //------------------------------------------------------------------------
369 class GfxSeparationColorSpace: public GfxColorSpace {
372 GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
374 virtual ~GfxSeparationColorSpace();
375 virtual GfxColorSpace *copy();
376 virtual GfxColorSpaceMode getMode() { return csSeparation; }
378 // Construct a Separation color space. Returns NULL if unsuccessful.
379 static GfxColorSpace *parse(Array *arr);
381 virtual void getGray(GfxColor *color, double *gray);
382 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
383 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
385 virtual int getNComps() { return 1; }
387 // Separation-specific access.
388 GString *getName() { return name; }
389 GfxColorSpace *getAlt() { return alt; }
390 Function *getFunc() { return func; }
394 GString *name; // colorant name
395 GfxColorSpace *alt; // alternate color space
396 Function *func; // tint transform (into alternate color space)
399 //------------------------------------------------------------------------
400 // GfxDeviceNColorSpace
401 //------------------------------------------------------------------------
403 class GfxDeviceNColorSpace: public GfxColorSpace {
406 GfxDeviceNColorSpace(int nCompsA, GfxColorSpace *alt, Function *func);
407 virtual ~GfxDeviceNColorSpace();
408 virtual GfxColorSpace *copy();
409 virtual GfxColorSpaceMode getMode() { return csDeviceN; }
411 // Construct a DeviceN color space. Returns NULL if unsuccessful.
412 static GfxColorSpace *parse(Array *arr);
414 virtual void getGray(GfxColor *color, double *gray);
415 virtual void getRGB(GfxColor *color, GfxRGB *rgb);
416 virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
418 virtual int getNComps() { return nComps; }
420 // DeviceN-specific access.
421 GString *getColorantName(int i) { return names[i]; }
422 GfxColorSpace *getAlt() { return alt; }
423 Function *getTintTransformFunc() { return func; }
427 int nComps; // number of components
428 GString // colorant names
429 *names[gfxColorMaxComps];
430 GfxColorSpace *alt; // alternate color space
431 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 static GfxTilingPattern *parse(Object *patObj);
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(int paintTypeA, int tilingTypeA,
510 double *bboxA, double xStepA, double yStepA,
511 Object *resDictA, double *matrixA,
512 Object *contentStreamA);
520 Object contentStream;
523 //------------------------------------------------------------------------
525 //------------------------------------------------------------------------
527 class GfxShadingPattern: public GfxPattern {
530 static GfxShadingPattern *parse(Object *patObj);
531 virtual ~GfxShadingPattern();
533 virtual GfxPattern *copy();
535 GfxShading *getShading() { return shading; }
536 double *getMatrix() { return matrix; }
540 GfxShadingPattern(GfxShading *shadingA, double *matrixA);
546 //------------------------------------------------------------------------
548 //------------------------------------------------------------------------
553 GfxShading(int typeA);
554 GfxShading(GfxShading *shading);
555 virtual ~GfxShading();
557 static GfxShading *parse(Object *obj);
559 virtual GfxShading *copy() = 0;
561 int getType() { return type; }
562 GfxColorSpace *getColorSpace() { return colorSpace; }
563 GfxColor *getBackground() { return &background; }
564 GBool getHasBackground() { return hasBackground; }
565 void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
566 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
567 GBool getHasBBox() { return hasBBox; }
571 GBool init(Dict *dict);
574 GfxColorSpace *colorSpace;
577 double xMin, yMin, xMax, yMax;
581 //------------------------------------------------------------------------
582 // GfxFunctionShading
583 //------------------------------------------------------------------------
585 class GfxFunctionShading: public GfxShading {
588 GfxFunctionShading(double x0A, double y0A,
589 double x1A, double y1A,
591 Function **funcsA, int nFuncsA);
592 GfxFunctionShading(GfxFunctionShading *shading);
593 virtual ~GfxFunctionShading();
595 static GfxFunctionShading *parse(Dict *dict);
597 virtual GfxShading *copy();
599 void getDomain(double *x0A, double *y0A, double *x1A, double *y1A)
600 { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
601 double *getMatrix() { return matrix; }
602 void getColor(double x, double y, GfxColor *color);
606 double x0, y0, x1, y1;
608 Function *funcs[gfxColorMaxComps];
612 //------------------------------------------------------------------------
614 //------------------------------------------------------------------------
616 class GfxAxialShading: public GfxShading {
619 GfxAxialShading(double x0A, double y0A,
620 double x1A, double y1A,
621 double t0A, double t1A,
622 Function **funcsA, int nFuncsA,
623 GBool extend0A, GBool extend1A);
624 GfxAxialShading(GfxAxialShading *shading);
625 virtual ~GfxAxialShading();
627 static GfxAxialShading *parse(Dict *dict);
629 virtual GfxShading *copy();
631 void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
632 { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
633 double getDomain0() { return t0; }
634 double getDomain1() { return t1; }
635 void getColor(double t, GfxColor *color);
636 GBool getExtend0() { return extend0; }
637 GBool getExtend1() { return extend1; }
641 double x0, y0, x1, y1;
643 Function *funcs[gfxColorMaxComps];
645 GBool extend0, extend1;
648 //------------------------------------------------------------------------
650 //------------------------------------------------------------------------
652 class GfxRadialShading: public GfxShading {
655 GfxRadialShading(double x0A, double y0A, double r0A,
656 double x1A, double y1A, double r1A,
657 double t0A, double t1A,
658 Function **funcsA, int nFuncsA,
659 GBool extend0A, GBool extend1A);
660 GfxRadialShading(GfxRadialShading *shading);
661 virtual ~GfxRadialShading();
663 static GfxRadialShading *parse(Dict *dict);
665 virtual GfxShading *copy();
667 void getCoords(double *x0A, double *y0A, double *r0A,
668 double *x1A, double *y1A, double *r1A)
669 { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
670 double getDomain0() { return t0; }
671 double getDomain1() { return t1; }
672 void getColor(double t, GfxColor *color);
673 GBool getExtend0() { return extend0; }
674 GBool getExtend1() { return extend1; }
678 double x0, y0, r0, x1, y1, r1;
680 Function *funcs[gfxColorMaxComps];
682 GBool extend0, extend1;
685 //------------------------------------------------------------------------
687 //------------------------------------------------------------------------
689 class GfxImageColorMap {
693 GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
698 // Return a copy of this color map.
699 GfxImageColorMap *copy() { return new GfxImageColorMap(this); }
701 // Is color map valid?
702 GBool isOk() { return ok; }
704 // Get the color space.
705 GfxColorSpace *getColorSpace() { return colorSpace; }
707 // Get stream decoding info.
708 int getNumPixelComps() { return nComps; }
709 int getBits() { return bits; }
712 double getDecodeLow(int i) { return decodeLow[i]; }
713 double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
715 // Convert an image pixel to a color.
716 void getGray(Guchar *x, double *gray);
717 void getRGB(Guchar *x, GfxRGB *rgb);
718 void getCMYK(Guchar *x, GfxCMYK *cmyk);
719 void getColor(Guchar *x, GfxColor *color);
723 GfxImageColorMap(GfxImageColorMap *colorMap);
725 GfxColorSpace *colorSpace; // the image color space
726 int bits; // bits per component
727 int nComps; // number of components in a pixel
728 GfxColorSpace *colorSpace2; // secondary color space
729 int nComps2; // number of components in colorSpace2
730 double *lookup; // lookup table
731 double // minimum values for each component
732 decodeLow[gfxColorMaxComps];
733 double // max - min value for each component
734 decodeRange[gfxColorMaxComps];
738 //------------------------------------------------------------------------
739 // GfxSubpath and GfxPath
740 //------------------------------------------------------------------------
746 GfxSubpath(double x1, double y1);
752 GfxSubpath *copy() { return new GfxSubpath(this); }
755 int getNumPoints() { return n; }
756 double getX(int i) { return x[i]; }
757 double getY(int i) { return y[i]; }
758 GBool getCurve(int i) { return curve[i]; }
761 double getLastX() { return x[n-1]; }
762 double getLastY() { return y[n-1]; }
764 // Add a line segment.
765 void lineTo(double x1, double y1);
767 // Add a Bezier curve.
768 void curveTo(double x1, double y1, double x2, double y2,
769 double x3, double y3);
771 // Close the subpath.
773 GBool isClosed() { return closed; }
775 // Add (<dx>, <dy>) to each point in the subpath.
776 void offset(double dx, double dy);
780 double *x, *y; // points
781 GBool *curve; // curve[i] => point i is a control point
782 // for a Bezier curve
783 int n; // number of points
784 int size; // size of x/y arrays
785 GBool closed; // set if path is closed
787 GfxSubpath(GfxSubpath *subpath);
801 { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
803 // Is there a current point?
804 GBool isCurPt() { return n > 0 || justMoved; }
806 // Is the path non-empty, i.e., is there at least one segment?
807 GBool isPath() { return n > 0; }
810 int getNumSubpaths() { return n; }
811 GfxSubpath *getSubpath(int i) { return subpaths[i]; }
813 // Get last point on last subpath.
814 double getLastX() { return subpaths[n-1]->getLastX(); }
815 double getLastY() { return subpaths[n-1]->getLastY(); }
817 // Move the current point.
818 void moveTo(double x, double y);
820 // Add a segment to the last subpath.
821 void lineTo(double x, double y);
823 // Add a Bezier curve to the last subpath
824 void curveTo(double x1, double y1, double x2, double y2,
825 double x3, double y3);
827 // Close the last subpath.
830 // Append <path> to <this>.
831 void append(GfxPath *path);
833 // Add (<dx>, <dy>) to each point in the path.
834 void offset(double dx, double dy);
838 GBool justMoved; // set if a new subpath was just started
839 double firstX, firstY; // first point in new subpath
840 GfxSubpath **subpaths; // subpaths
841 int n; // number of subpaths
842 int size; // size of subpaths array
844 GfxPath(GBool justMoved1, double firstX1, double firstY1,
845 GfxSubpath **subpaths1, int n1, int size1);
848 //------------------------------------------------------------------------
850 //------------------------------------------------------------------------
855 // Construct a default GfxState, for a device with resolution <hDPI>
856 // x <vDPI>, page box <pageBox>, page rotation <rotate>, and
857 // coordinate system specified by <upsideDown>.
858 GfxState(double hDPI, double vDPI, PDFRectangle *pageBox,
859 int rotate, GBool upsideDown);
865 GfxState *copy() { return new GfxState(this); }
868 double *getCTM() { return ctm; }
869 double getX1() { return px1; }
870 double getY1() { return py1; }
871 double getX2() { return px2; }
872 double getY2() { return py2; }
873 double getPageWidth() { return pageWidth; }
874 double getPageHeight() { return pageHeight; }
875 GfxColor *getFillColor() { return &fillColor; }
876 GfxColor *getStrokeColor() { return &strokeColor; }
877 void getFillGray(double *gray)
878 { fillColorSpace->getGray(&fillColor, gray); }
879 void getStrokeGray(double *gray)
880 { strokeColorSpace->getGray(&strokeColor, gray); }
881 void getFillRGB(GfxRGB *rgb)
882 { fillColorSpace->getRGB(&fillColor, rgb); }
883 void getStrokeRGB(GfxRGB *rgb)
884 { strokeColorSpace->getRGB(&strokeColor, rgb); }
885 void getFillCMYK(GfxCMYK *cmyk)
886 { fillColorSpace->getCMYK(&fillColor, cmyk); }
887 void getStrokeCMYK(GfxCMYK *cmyk)
888 { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
889 GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
890 GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
891 GfxPattern *getFillPattern() { return fillPattern; }
892 GfxPattern *getStrokePattern() { return strokePattern; }
893 double getFillOpacity() { return fillOpacity; }
894 double getStrokeOpacity() { return strokeOpacity; }
895 double getLineWidth() { return lineWidth; }
896 void getLineDash(double **dash, int *length, double *start)
897 { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
898 int getFlatness() { return flatness; }
899 int getLineJoin() { return lineJoin; }
900 int getLineCap() { return lineCap; }
901 double getMiterLimit() { return miterLimit; }
902 GfxFont *getFont() { return font; }
903 double getFontSize() { return fontSize; }
904 double *getTextMat() { return textMat; }
905 double getCharSpace() { return charSpace; }
906 double getWordSpace() { return wordSpace; }
907 double getHorizScaling() { return horizScaling; }
908 double getLeading() { return leading; }
909 double getRise() { return rise; }
910 int getRender() { return render; }
911 GfxPath *getPath() { return path; }
912 void setPath(GfxPath *pathA);
913 double getCurX() { return curX; }
914 double getCurY() { return curY; }
915 void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax)
916 { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
917 void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
918 double getLineX() { return lineX; }
919 double getLineY() { return lineY; }
921 // Is there a current point/path?
922 GBool isCurPt() { return path->isCurPt(); }
923 GBool isPath() { return path->isPath(); }
926 void transform(double x1, double y1, double *x2, double *y2)
927 { *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
928 *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
929 void transformDelta(double x1, double y1, double *x2, double *y2)
930 { *x2 = ctm[0] * x1 + ctm[2] * y1;
931 *y2 = ctm[1] * x1 + ctm[3] * y1; }
932 void textTransform(double x1, double y1, double *x2, double *y2)
933 { *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
934 *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
935 void textTransformDelta(double x1, double y1, double *x2, double *y2)
936 { *x2 = textMat[0] * x1 + textMat[2] * y1;
937 *y2 = textMat[1] * x1 + textMat[3] * y1; }
938 double transformWidth(double w);
939 double getTransformedLineWidth()
940 { return transformWidth(lineWidth); }
941 double getTransformedFontSize();
942 void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
944 // Change state parameters.
945 void setCTM(double a, double b, double c,
946 double d, double e, double f);
947 void concatCTM(double a, double b, double c,
948 double d, double e, double f);
949 void setFillColorSpace(GfxColorSpace *colorSpace);
950 void setStrokeColorSpace(GfxColorSpace *colorSpace);
951 void setFillColor(GfxColor *color) { fillColor = *color; }
952 void setStrokeColor(GfxColor *color) { strokeColor = *color; }
953 void setFillPattern(GfxPattern *pattern);
954 void setStrokePattern(GfxPattern *pattern);
955 void setFillOpacity(double opac) { fillOpacity = opac; }
956 void setStrokeOpacity(double opac) { strokeOpacity = opac; }
957 void setLineWidth(double width) { lineWidth = width; }
958 void setLineDash(double *dash, int length, double start);
959 void setFlatness(int flatness1) { flatness = flatness1; }
960 void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
961 void setLineCap(int lineCap1) { lineCap = lineCap1; }
962 void setMiterLimit(double limit) { miterLimit = limit; }
963 void setFont(GfxFont *fontA, double fontSizeA)
964 { font = fontA; fontSize = fontSizeA; }
965 void setTextMat(double a, double b, double c,
966 double d, double e, double f)
967 { textMat[0] = a; textMat[1] = b; textMat[2] = c;
968 textMat[3] = d; textMat[4] = e; textMat[5] = f; }
969 void setCharSpace(double space)
970 { charSpace = space; }
971 void setWordSpace(double space)
972 { wordSpace = space; }
973 void setHorizScaling(double scale)
974 { horizScaling = 0.01 * scale; }
975 void setLeading(double leadingA)
976 { leading = leadingA; }
977 void setRise(double riseA)
979 void setRender(int renderA)
980 { render = renderA; }
983 void moveTo(double x, double y)
984 { path->moveTo(curX = x, curY = y); }
985 void lineTo(double x, double y)
986 { path->lineTo(curX = x, curY = y); }
987 void curveTo(double x1, double y1, double x2, double y2,
988 double x3, double y3)
989 { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
991 { path->close(); curX = path->getLastX(); curY = path->getLastY(); }
994 // Update clip region.
998 void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; }
999 void textMoveTo(double tx, double ty)
1000 { lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
1001 void textShift(double tx, double ty);
1002 void shift(double dx, double dy);
1004 // Push/pop GfxState on/off stack.
1006 GfxState *restore();
1007 GBool hasSaves() { return saved != NULL; }
1011 double ctm[6]; // coord transform matrix
1012 double px1, py1, px2, py2; // page corners (user coords)
1013 double pageWidth, pageHeight; // page size (pixels)
1015 GfxColorSpace *fillColorSpace; // fill color space
1016 GfxColorSpace *strokeColorSpace; // stroke color space
1017 GfxColor fillColor; // fill color
1018 GfxColor strokeColor; // stroke color
1019 GfxPattern *fillPattern; // fill pattern
1020 GfxPattern *strokePattern; // stroke pattern
1021 double fillOpacity; // fill opacity
1022 double strokeOpacity; // stroke opacity
1024 double lineWidth; // line width
1025 double *lineDash; // line dash
1027 double lineDashStart;
1028 int flatness; // curve flatness
1029 int lineJoin; // line join style
1030 int lineCap; // line cap style
1031 double miterLimit; // line miter limit
1033 GfxFont *font; // font
1034 double fontSize; // font size
1035 double textMat[6]; // text matrix
1036 double charSpace; // character spacing
1037 double wordSpace; // word spacing
1038 double horizScaling; // horizontal scaling
1039 double leading; // text leading
1040 double rise; // text rise
1041 int render; // text rendering mode
1043 GfxPath *path; // array of path elements
1044 double curX, curY; // current point (user coords)
1045 double lineX, lineY; // start of current text line (text coords)
1047 double clipXMin, clipYMin, // bounding box for clip region
1050 GfxState *saved; // next GfxState on stack
1052 GfxState(GfxState *state);