1 //========================================================================
5 // Copyright 1996-2002 Glyph & Cog, LLC
7 //========================================================================
24 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
28 #define gfxColorMaxComps funcMaxOutputs
31 double c
[gfxColorMaxComps
];
34 //------------------------------------------------------------------------
36 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
44 //------------------------------------------------------------------------
50 //------------------------------------------------------------------------
52 //------------------------------------------------------------------------
54 enum GfxColorSpaceMode
{
72 virtual ~GfxColorSpace();
73 virtual GfxColorSpace
*copy() = 0;
74 virtual GfxColorSpaceMode
getMode() = 0;
76 // Construct a color space. Returns NULL if unsuccessful.
77 static GfxColorSpace
*parse(Object
*csObj
);
79 // Convert to gray, RGB, or CMYK.
80 virtual void getGray(GfxColor
*color
, double *gray
) = 0;
81 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
) = 0;
82 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
) = 0;
84 // Return the number of color components.
85 virtual int getNComps() = 0;
87 // Return the default ranges for each component, assuming an image
88 // with a max pixel value of <maxImgPixel>.
89 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
95 //------------------------------------------------------------------------
96 // GfxDeviceGrayColorSpace
97 //------------------------------------------------------------------------
99 class GfxDeviceGrayColorSpace
: public GfxColorSpace
{
102 GfxDeviceGrayColorSpace();
103 virtual ~GfxDeviceGrayColorSpace();
104 virtual GfxColorSpace
*copy();
105 virtual GfxColorSpaceMode
getMode() { return csDeviceGray
; }
107 virtual void getGray(GfxColor
*color
, double *gray
);
108 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
109 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
111 virtual int getNComps() { return 1; }
116 //------------------------------------------------------------------------
117 // GfxCalGrayColorSpace
118 //------------------------------------------------------------------------
120 class GfxCalGrayColorSpace
: public GfxColorSpace
{
123 GfxCalGrayColorSpace();
124 virtual ~GfxCalGrayColorSpace();
125 virtual GfxColorSpace
*copy();
126 virtual GfxColorSpaceMode
getMode() { return csCalGray
; }
128 // Construct a CalGray color space. Returns NULL if unsuccessful.
129 static GfxColorSpace
*parse(Array
*arr
);
131 virtual void getGray(GfxColor
*color
, double *gray
);
132 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
133 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
135 virtual int getNComps() { return 1; }
137 // CalGray-specific access.
138 double getWhiteX() { return whiteX
; }
139 double getWhiteY() { return whiteY
; }
140 double getWhiteZ() { return whiteZ
; }
141 double getBlackX() { return blackX
; }
142 double getBlackY() { return blackY
; }
143 double getBlackZ() { return blackZ
; }
144 double getGamma() { return gamma
; }
148 double whiteX
, whiteY
, whiteZ
; // white point
149 double blackX
, blackY
, blackZ
; // black point
150 double gamma
; // gamma value
153 //------------------------------------------------------------------------
154 // GfxDeviceRGBColorSpace
155 //------------------------------------------------------------------------
157 class GfxDeviceRGBColorSpace
: public GfxColorSpace
{
160 GfxDeviceRGBColorSpace();
161 virtual ~GfxDeviceRGBColorSpace();
162 virtual GfxColorSpace
*copy();
163 virtual GfxColorSpaceMode
getMode() { return csDeviceRGB
; }
165 virtual void getGray(GfxColor
*color
, double *gray
);
166 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
167 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
169 virtual int getNComps() { return 3; }
174 //------------------------------------------------------------------------
175 // GfxCalRGBColorSpace
176 //------------------------------------------------------------------------
178 class GfxCalRGBColorSpace
: public GfxColorSpace
{
181 GfxCalRGBColorSpace();
182 virtual ~GfxCalRGBColorSpace();
183 virtual GfxColorSpace
*copy();
184 virtual GfxColorSpaceMode
getMode() { return csCalRGB
; }
186 // Construct a CalRGB color space. Returns NULL if unsuccessful.
187 static GfxColorSpace
*parse(Array
*arr
);
189 virtual void getGray(GfxColor
*color
, double *gray
);
190 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
191 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
193 virtual int getNComps() { return 3; }
195 // CalRGB-specific access.
196 double getWhiteX() { return whiteX
; }
197 double getWhiteY() { return whiteY
; }
198 double getWhiteZ() { return whiteZ
; }
199 double getBlackX() { return blackX
; }
200 double getBlackY() { return blackY
; }
201 double getBlackZ() { return blackZ
; }
202 double getGammaR() { return gammaR
; }
203 double getGammaG() { return gammaG
; }
204 double getGammaB() { return gammaB
; }
205 double *getMatrix() { return mat
; }
209 double whiteX
, whiteY
, whiteZ
; // white point
210 double blackX
, blackY
, blackZ
; // black point
211 double gammaR
, gammaG
, gammaB
; // gamma values
212 double mat
[9]; // ABC -> XYZ transform matrix
215 //------------------------------------------------------------------------
216 // GfxDeviceCMYKColorSpace
217 //------------------------------------------------------------------------
219 class GfxDeviceCMYKColorSpace
: public GfxColorSpace
{
222 GfxDeviceCMYKColorSpace();
223 virtual ~GfxDeviceCMYKColorSpace();
224 virtual GfxColorSpace
*copy();
225 virtual GfxColorSpaceMode
getMode() { return csDeviceCMYK
; }
227 virtual void getGray(GfxColor
*color
, double *gray
);
228 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
229 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
231 virtual int getNComps() { return 4; }
236 //------------------------------------------------------------------------
238 //------------------------------------------------------------------------
240 class GfxLabColorSpace
: public GfxColorSpace
{
244 virtual ~GfxLabColorSpace();
245 virtual GfxColorSpace
*copy();
246 virtual GfxColorSpaceMode
getMode() { return csLab
; }
248 // Construct a Lab color space. Returns NULL if unsuccessful.
249 static GfxColorSpace
*parse(Array
*arr
);
251 virtual void getGray(GfxColor
*color
, double *gray
);
252 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
253 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
255 virtual int getNComps() { return 3; }
257 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
260 // Lab-specific access.
261 double getWhiteX() { return whiteX
; }
262 double getWhiteY() { return whiteY
; }
263 double getWhiteZ() { return whiteZ
; }
264 double getBlackX() { return blackX
; }
265 double getBlackY() { return blackY
; }
266 double getBlackZ() { return blackZ
; }
267 double getAMin() { return aMin
; }
268 double getAMax() { return aMax
; }
269 double getBMin() { return bMin
; }
270 double getBMax() { return bMax
; }
274 double whiteX
, whiteY
, whiteZ
; // white point
275 double blackX
, blackY
, blackZ
; // black point
276 double aMin
, aMax
, bMin
, bMax
; // range for the a and b components
277 double kr
, kg
, kb
; // gamut mapping mulitpliers
280 //------------------------------------------------------------------------
281 // GfxICCBasedColorSpace
282 //------------------------------------------------------------------------
284 class GfxICCBasedColorSpace
: public GfxColorSpace
{
287 GfxICCBasedColorSpace(int nCompsA
, GfxColorSpace
*altA
,
288 Ref
*iccProfileStreamA
);
289 virtual ~GfxICCBasedColorSpace();
290 virtual GfxColorSpace
*copy();
291 virtual GfxColorSpaceMode
getMode() { return csICCBased
; }
293 // Construct an ICCBased color space. Returns NULL if unsuccessful.
294 static GfxColorSpace
*parse(Array
*arr
);
296 virtual void getGray(GfxColor
*color
, double *gray
);
297 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
298 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
300 virtual int getNComps() { return nComps
; }
302 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
305 // ICCBased-specific access.
306 GfxColorSpace
*getAlt() { return alt
; }
310 int nComps
; // number of color components (1, 3, or 4)
311 GfxColorSpace
*alt
; // alternate color space
312 double rangeMin
[4]; // min values for each component
313 double rangeMax
[4]; // max values for each component
314 Ref iccProfileStream
; // the ICC profile
317 //------------------------------------------------------------------------
318 // GfxIndexedColorSpace
319 //------------------------------------------------------------------------
321 class GfxIndexedColorSpace
: public GfxColorSpace
{
324 GfxIndexedColorSpace(GfxColorSpace
*baseA
, int indexHighA
);
325 virtual ~GfxIndexedColorSpace();
326 virtual GfxColorSpace
*copy();
327 virtual GfxColorSpaceMode
getMode() { return csIndexed
; }
329 // Construct a Lab color space. Returns NULL if unsuccessful.
330 static GfxColorSpace
*parse(Array
*arr
);
332 virtual void getGray(GfxColor
*color
, double *gray
);
333 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
334 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
336 virtual int getNComps() { return 1; }
338 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
341 // Indexed-specific access.
342 GfxColorSpace
*getBase() { return base
; }
343 int getIndexHigh() { return indexHigh
; }
344 Guchar
*getLookup() { return lookup
; }
348 GfxColorSpace
*base
; // base color space
349 int indexHigh
; // max pixel value
350 Guchar
*lookup
; // lookup table
353 //------------------------------------------------------------------------
354 // GfxSeparationColorSpace
355 //------------------------------------------------------------------------
357 class GfxSeparationColorSpace
: public GfxColorSpace
{
360 GfxSeparationColorSpace(GString
*nameA
, GfxColorSpace
*altA
,
362 virtual ~GfxSeparationColorSpace();
363 virtual GfxColorSpace
*copy();
364 virtual GfxColorSpaceMode
getMode() { return csSeparation
; }
366 // Construct a Separation color space. Returns NULL if unsuccessful.
367 static GfxColorSpace
*parse(Array
*arr
);
369 virtual void getGray(GfxColor
*color
, double *gray
);
370 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
371 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
373 virtual int getNComps() { return 1; }
375 // Separation-specific access.
376 GString
*getName() { return name
; }
377 GfxColorSpace
*getAlt() { return alt
; }
378 Function
*getFunc() { return func
; }
382 GString
*name
; // colorant name
383 GfxColorSpace
*alt
; // alternate color space
384 Function
*func
; // tint transform (into alternate color space)
387 //------------------------------------------------------------------------
388 // GfxDeviceNColorSpace
389 //------------------------------------------------------------------------
391 class GfxDeviceNColorSpace
: public GfxColorSpace
{
394 GfxDeviceNColorSpace(int nComps
, GfxColorSpace
*alt
, Function
*func
);
395 virtual ~GfxDeviceNColorSpace();
396 virtual GfxColorSpace
*copy();
397 virtual GfxColorSpaceMode
getMode() { return csDeviceN
; }
399 // Construct a DeviceN color space. Returns NULL if unsuccessful.
400 static GfxColorSpace
*parse(Array
*arr
);
402 virtual void getGray(GfxColor
*color
, double *gray
);
403 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
404 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
406 virtual int getNComps() { return nComps
; }
408 // DeviceN-specific access.
409 GfxColorSpace
*getAlt() { return alt
; }
413 int nComps
; // number of components
414 GString
// colorant names
415 *names
[gfxColorMaxComps
];
416 GfxColorSpace
*alt
; // alternate color space
417 Function
*func
; // tint transform (into alternate color space)
421 //------------------------------------------------------------------------
422 // GfxPatternColorSpace
423 //------------------------------------------------------------------------
425 class GfxPatternColorSpace
: public GfxColorSpace
{
428 GfxPatternColorSpace(GfxColorSpace
*underA
);
429 virtual ~GfxPatternColorSpace();
430 virtual GfxColorSpace
*copy();
431 virtual GfxColorSpaceMode
getMode() { return csPattern
; }
433 // Construct a Pattern color space. Returns NULL if unsuccessful.
434 static GfxColorSpace
*parse(Array
*arr
);
436 virtual void getGray(GfxColor
*color
, double *gray
);
437 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
438 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
440 virtual int getNComps() { return 0; }
442 // Pattern-specific access.
443 GfxColorSpace
*getUnder() { return under
; }
447 GfxColorSpace
*under
; // underlying color space (for uncolored
451 //------------------------------------------------------------------------
453 //------------------------------------------------------------------------
458 GfxPattern(int typeA
);
459 virtual ~GfxPattern();
461 static GfxPattern
*parse(Object
*obj
);
463 virtual GfxPattern
*copy() = 0;
465 int getType() { return type
; }
472 //------------------------------------------------------------------------
474 //------------------------------------------------------------------------
476 class GfxTilingPattern
: public GfxPattern
{
479 GfxTilingPattern(Dict
*streamDict
, Object
*stream
);
480 virtual ~GfxTilingPattern();
482 virtual GfxPattern
*copy();
484 int getPaintType() { return paintType
; }
485 int getTilingType() { return tilingType
; }
486 double *getBBox() { return bbox
; }
487 double getXStep() { return xStep
; }
488 double getYStep() { return yStep
; }
490 { return resDict
.isDict() ? resDict
.getDict() : (Dict
*)NULL
; }
491 double *getMatrix() { return matrix
; }
492 Object
*getContentStream() { return &contentStream
; }
496 GfxTilingPattern(GfxTilingPattern
*pat
);
504 Object contentStream
;
507 //------------------------------------------------------------------------
509 //------------------------------------------------------------------------
515 virtual ~GfxShading();
517 static GfxShading
*parse(Object
*obj
);
519 int getType() { return type
; }
520 GfxColorSpace
*getColorSpace() { return colorSpace
; }
521 GfxColor
*getBackground() { return &background
; }
522 GBool
getHasBackground() { return hasBackground
; }
523 void getBBox(double *xMinA
, double *yMinA
, double *xMaxA
, double *yMaxA
)
524 { *xMinA
= xMin
; *yMinA
= yMin
; *xMaxA
= xMax
; *yMaxA
= yMax
; }
525 GBool
getHasBBox() { return hasBBox
; }
530 GfxColorSpace
*colorSpace
;
533 double xMin
, yMin
, xMax
, yMax
;
537 //------------------------------------------------------------------------
539 //------------------------------------------------------------------------
541 class GfxAxialShading
: public GfxShading
{
544 GfxAxialShading(double x0A
, double y0A
,
545 double x1A
, double y1A
,
546 double t0A
, double t1A
,
547 Function
**funcsA
, int nFuncsA
,
548 GBool extend0A
, GBool extend1A
);
549 virtual ~GfxAxialShading();
551 static GfxAxialShading
*parse(Dict
*dict
);
553 void getCoords(double *x0A
, double *y0A
, double *x1A
, double *y1A
)
554 { *x0A
= x0
; *y0A
= y0
; *x1A
= x1
; *y1A
= y1
; }
555 double getDomain0() { return t0
; }
556 double getDomain1() { return t1
; }
557 void getColor(double t
, GfxColor
*color
);
558 GBool
getExtend0() { return extend0
; }
559 GBool
getExtend1() { return extend1
; }
563 double x0
, y0
, x1
, y1
;
565 Function
*funcs
[gfxColorMaxComps
];
567 GBool extend0
, extend1
;
570 //------------------------------------------------------------------------
572 //------------------------------------------------------------------------
574 class GfxRadialShading
: public GfxShading
{
577 GfxRadialShading(double x0A
, double y0A
, double r0A
,
578 double x1A
, double y1A
, double r1A
,
579 double t0A
, double t1A
,
580 Function
**funcsA
, int nFuncsA
,
581 GBool extend0A
, GBool extend1A
);
582 virtual ~GfxRadialShading();
584 static GfxRadialShading
*parse(Dict
*dict
);
586 void getCoords(double *x0A
, double *y0A
, double *r0A
,
587 double *x1A
, double *y1A
, double *r1A
)
588 { *x0A
= x0
; *y0A
= y0
; *r0A
= r0
; *x1A
= x1
; *y1A
= y1
; *r1A
= r1
; }
589 double getDomain0() { return t0
; }
590 double getDomain1() { return t1
; }
591 void getColor(double t
, GfxColor
*color
);
592 GBool
getExtend0() { return extend0
; }
593 GBool
getExtend1() { return extend1
; }
597 double x0
, y0
, r0
, x1
, y1
, r1
;
599 Function
*funcs
[gfxColorMaxComps
];
601 GBool extend0
, extend1
;
604 //------------------------------------------------------------------------
606 //------------------------------------------------------------------------
608 class GfxImageColorMap
{
612 GfxImageColorMap(int bitsA
, Object
*decode
, GfxColorSpace
*colorSpaceA
);
617 // Is color map valid?
618 GBool
isOk() { return ok
; }
620 // Get the color space.
621 GfxColorSpace
*getColorSpace() { return colorSpace
; }
623 // Get stream decoding info.
624 int getNumPixelComps() { return nComps
; }
625 int getBits() { return bits
; }
628 double getDecodeLow(int i
) { return decodeLow
[i
]; }
629 double getDecodeHigh(int i
) { return decodeLow
[i
] + decodeRange
[i
]; }
631 // Convert an image pixel to a color.
632 void getGray(Guchar
*x
, double *gray
);
633 void getRGB(Guchar
*x
, GfxRGB
*rgb
);
634 void getCMYK(Guchar
*x
, GfxCMYK
*cmyk
);
638 GfxColorSpace
*colorSpace
; // the image color space
639 int bits
; // bits per component
640 int nComps
; // number of components in a pixel
641 GfxColorSpace
*colorSpace2
; // secondary color space
642 int nComps2
; // number of components in colorSpace2
643 double *lookup
; // lookup table
644 double // minimum values for each component
645 decodeLow
[gfxColorMaxComps
];
646 double // max - min value for each component
647 decodeRange
[gfxColorMaxComps
];
651 //------------------------------------------------------------------------
652 // GfxSubpath and GfxPath
653 //------------------------------------------------------------------------
659 GfxSubpath(double x1
, double y1
);
665 GfxSubpath
*copy() { return new GfxSubpath(this); }
668 int getNumPoints() { return n
; }
669 double getX(int i
) { return x
[i
]; }
670 double getY(int i
) { return y
[i
]; }
671 GBool
getCurve(int i
) { return curve
[i
]; }
674 double getLastX() { return x
[n
-1]; }
675 double getLastY() { return y
[n
-1]; }
677 // Add a line segment.
678 void lineTo(double x1
, double y1
);
680 // Add a Bezier curve.
681 void curveTo(double x1
, double y1
, double x2
, double y2
,
682 double x3
, double y3
);
684 // Close the subpath.
686 GBool
isClosed() { return closed
; }
690 double *x
, *y
; // points
691 GBool
*curve
; // curve[i] => point i is a control point
692 // for a Bezier curve
693 int n
; // number of points
694 int size
; // size of x/y arrays
695 GBool closed
; // set if path is closed
697 GfxSubpath(GfxSubpath
*subpath
);
711 { return new GfxPath(justMoved
, firstX
, firstY
, subpaths
, n
, size
); }
713 // Is there a current point?
714 GBool
isCurPt() { return n
> 0 || justMoved
; }
716 // Is the path non-empty, i.e., is there at least one segment?
717 GBool
isPath() { return n
> 0; }
720 int getNumSubpaths() { return n
; }
721 GfxSubpath
*getSubpath(int i
) { return subpaths
[i
]; }
723 // Get last point on last subpath.
724 double getLastX() { return subpaths
[n
-1]->getLastX(); }
725 double getLastY() { return subpaths
[n
-1]->getLastY(); }
727 // Move the current point.
728 void moveTo(double x
, double y
);
730 // Add a segment to the last subpath.
731 void lineTo(double x
, double y
);
733 // Add a Bezier curve to the last subpath
734 void curveTo(double x1
, double y1
, double x2
, double y2
,
735 double x3
, double y3
);
737 // Close the last subpath.
742 GBool justMoved
; // set if a new subpath was just started
743 double firstX
, firstY
; // first point in new subpath
744 GfxSubpath
**subpaths
; // subpaths
745 int n
; // number of subpaths
746 int size
; // size of subpaths array
748 GfxPath(GBool justMoved1
, double firstX1
, double firstY1
,
749 GfxSubpath
**subpaths1
, int n1
, int size1
);
752 //------------------------------------------------------------------------
754 //------------------------------------------------------------------------
759 // Construct a default GfxState, for a device with resolution <dpi>,
760 // page box <pageBox>, page rotation <rotate>, and coordinate system
761 // specified by <upsideDown>.
762 GfxState(double dpi
, PDFRectangle
*pageBox
, int rotate
,
769 GfxState
*copy() { return new GfxState(this); }
772 double *getCTM() { return ctm
; }
773 double getX1() { return px1
; }
774 double getY1() { return py1
; }
775 double getX2() { return px2
; }
776 double getY2() { return py2
; }
777 double getPageWidth() { return pageWidth
; }
778 double getPageHeight() { return pageHeight
; }
779 GfxColor
*getFillColor() { return &fillColor
; }
780 GfxColor
*getStrokeColor() { return &strokeColor
; }
781 void getFillGray(double *gray
)
782 { fillColorSpace
->getGray(&fillColor
, gray
); }
783 void getStrokeGray(double *gray
)
784 { strokeColorSpace
->getGray(&fillColor
, gray
); }
785 void getFillRGB(GfxRGB
*rgb
)
786 { fillColorSpace
->getRGB(&fillColor
, rgb
); }
787 void getStrokeRGB(GfxRGB
*rgb
)
788 { strokeColorSpace
->getRGB(&strokeColor
, rgb
); }
789 void getFillCMYK(GfxCMYK
*cmyk
)
790 { fillColorSpace
->getCMYK(&fillColor
, cmyk
); }
791 void getStrokeCMYK(GfxCMYK
*cmyk
)
792 { strokeColorSpace
->getCMYK(&strokeColor
, cmyk
); }
793 GfxColorSpace
*getFillColorSpace() { return fillColorSpace
; }
794 GfxColorSpace
*getStrokeColorSpace() { return strokeColorSpace
; }
795 GfxPattern
*getFillPattern() { return fillPattern
; }
796 GfxPattern
*getStrokePattern() { return strokePattern
; }
797 double getFillOpacity() { return fillOpacity
; }
798 double getStrokeOpacity() { return strokeOpacity
; }
799 double getLineWidth() { return lineWidth
; }
800 void getLineDash(double **dash
, int *length
, double *start
)
801 { *dash
= lineDash
; *length
= lineDashLength
; *start
= lineDashStart
; }
802 int getFlatness() { return flatness
; }
803 int getLineJoin() { return lineJoin
; }
804 int getLineCap() { return lineCap
; }
805 double getMiterLimit() { return miterLimit
; }
806 GfxFont
*getFont() { return font
; }
807 double getFontSize() { return fontSize
; }
808 double *getTextMat() { return textMat
; }
809 double getCharSpace() { return charSpace
; }
810 double getWordSpace() { return wordSpace
; }
811 double getHorizScaling() { return horizScaling
; }
812 double getLeading() { return leading
; }
813 double getRise() { return rise
; }
814 int getRender() { return render
; }
815 GfxPath
*getPath() { return path
; }
816 double getCurX() { return curX
; }
817 double getCurY() { return curY
; }
818 void getClipBBox(double *xMin
, double *yMin
, double *xMax
, double *yMax
)
819 { *xMin
= clipXMin
; *yMin
= clipYMin
; *xMax
= clipXMax
; *yMax
= clipYMax
; }
820 void getUserClipBBox(double *xMin
, double *yMin
, double *xMax
, double *yMax
);
821 double getLineX() { return lineX
; }
822 double getLineY() { return lineY
; }
824 // Is there a current point/path?
825 GBool
isCurPt() { return path
->isCurPt(); }
826 GBool
isPath() { return path
->isPath(); }
829 void transform(double x1
, double y1
, double *x2
, double *y2
)
830 { *x2
= ctm
[0] * x1
+ ctm
[2] * y1
+ ctm
[4];
831 *y2
= ctm
[1] * x1
+ ctm
[3] * y1
+ ctm
[5]; }
832 void transformDelta(double x1
, double y1
, double *x2
, double *y2
)
833 { *x2
= ctm
[0] * x1
+ ctm
[2] * y1
;
834 *y2
= ctm
[1] * x1
+ ctm
[3] * y1
; }
835 void textTransform(double x1
, double y1
, double *x2
, double *y2
)
836 { *x2
= textMat
[0] * x1
+ textMat
[2] * y1
+ textMat
[4];
837 *y2
= textMat
[1] * x1
+ textMat
[3] * y1
+ textMat
[5]; }
838 void textTransformDelta(double x1
, double y1
, double *x2
, double *y2
)
839 { *x2
= textMat
[0] * x1
+ textMat
[2] * y1
;
840 *y2
= textMat
[1] * x1
+ textMat
[3] * y1
; }
841 double transformWidth(double w
);
842 double getTransformedLineWidth()
843 { return transformWidth(lineWidth
); }
844 double getTransformedFontSize();
845 void getFontTransMat(double *m11
, double *m12
, double *m21
, double *m22
);
847 // Change state parameters.
848 void setCTM(double a
, double b
, double c
,
849 double d
, double e
, double f
);
850 void concatCTM(double a
, double b
, double c
,
851 double d
, double e
, double f
);
852 void setFillColorSpace(GfxColorSpace
*colorSpace
);
853 void setStrokeColorSpace(GfxColorSpace
*colorSpace
);
854 void setFillColor(GfxColor
*color
) { fillColor
= *color
; }
855 void setStrokeColor(GfxColor
*color
) { strokeColor
= *color
; }
856 void setFillPattern(GfxPattern
*pattern
);
857 void setStrokePattern(GfxPattern
*pattern
);
858 void setFillOpacity(double opac
) { fillOpacity
= opac
; }
859 void setStrokeOpacity(double opac
) { strokeOpacity
= opac
; }
860 void setLineWidth(double width
) { lineWidth
= width
; }
861 void setLineDash(double *dash
, int length
, double start
);
862 void setFlatness(int flatness1
) { flatness
= flatness1
; }
863 void setLineJoin(int lineJoin1
) { lineJoin
= lineJoin1
; }
864 void setLineCap(int lineCap1
) { lineCap
= lineCap1
; }
865 void setMiterLimit(double limit
) { miterLimit
= limit
; }
866 void setFont(GfxFont
*fontA
, double fontSizeA
)
867 { font
= fontA
; fontSize
= fontSizeA
; }
868 void setTextMat(double a
, double b
, double c
,
869 double d
, double e
, double f
)
870 { textMat
[0] = a
; textMat
[1] = b
; textMat
[2] = c
;
871 textMat
[3] = d
; textMat
[4] = e
; textMat
[5] = f
; }
872 void setCharSpace(double space
)
873 { charSpace
= space
; }
874 void setWordSpace(double space
)
875 { wordSpace
= space
; }
876 void setHorizScaling(double scale
)
877 { horizScaling
= 0.01 * scale
; }
878 void setLeading(double leadingA
)
879 { leading
= leadingA
; }
880 void setRise(double riseA
)
882 void setRender(int renderA
)
883 { render
= renderA
; }
886 void moveTo(double x
, double y
)
887 { path
->moveTo(curX
= x
, curY
= y
); }
888 void lineTo(double x
, double y
)
889 { path
->lineTo(curX
= x
, curY
= y
); }
890 void curveTo(double x1
, double y1
, double x2
, double y2
,
891 double x3
, double y3
)
892 { path
->curveTo(x1
, y1
, x2
, y2
, curX
= x3
, curY
= y3
); }
894 { path
->close(); curX
= path
->getLastX(); curY
= path
->getLastY(); }
897 // Update clip region.
901 void textMoveTo(double tx
, double ty
)
902 { lineX
= tx
; lineY
= ty
; textTransform(tx
, ty
, &curX
, &curY
); }
903 void textShift(double tx
, double ty
);
904 void shift(double dx
, double dy
);
906 // Push/pop GfxState on/off stack.
909 GBool
hasSaves() { return saved
!= NULL
; }
913 double ctm
[6]; // coord transform matrix
914 double px1
, py1
, px2
, py2
; // page corners (user coords)
915 double pageWidth
, pageHeight
; // page size (pixels)
917 GfxColorSpace
*fillColorSpace
; // fill color space
918 GfxColorSpace
*strokeColorSpace
; // stroke color space
919 GfxColor fillColor
; // fill color
920 GfxColor strokeColor
; // stroke color
921 GfxPattern
*fillPattern
; // fill pattern
922 GfxPattern
*strokePattern
; // stroke pattern
923 double fillOpacity
; // fill opacity
924 double strokeOpacity
; // stroke opacity
926 double lineWidth
; // line width
927 double *lineDash
; // line dash
929 double lineDashStart
;
930 int flatness
; // curve flatness
931 int lineJoin
; // line join style
932 int lineCap
; // line cap style
933 double miterLimit
; // line miter limit
935 GfxFont
*font
; // font
936 double fontSize
; // font size
937 double textMat
[6]; // text matrix
938 double charSpace
; // character spacing
939 double wordSpace
; // word spacing
940 double horizScaling
; // horizontal scaling
941 double leading
; // text leading
942 double rise
; // text rise
943 int render
; // text rendering mode
945 GfxPath
*path
; // array of path elements
946 double curX
, curY
; // current point (user coords)
947 double lineX
, lineY
; // start of current text line (text coords)
949 double clipXMin
, clipYMin
, // bounding box for clip region
952 GfxState
*saved
; // next GfxState on stack
954 GfxState(GfxState
*state
);