]>
git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/GfxState.h
2056c4d1fb36f6f110a82fbb08d103f3e3e64e4e
1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
23 //------------------------------------------------------------------------
25 //------------------------------------------------------------------------
27 #define gfxColorMaxComps 8
30 double c
[gfxColorMaxComps
];
33 //------------------------------------------------------------------------
35 //------------------------------------------------------------------------
41 //------------------------------------------------------------------------
43 //------------------------------------------------------------------------
49 //------------------------------------------------------------------------
51 //------------------------------------------------------------------------
53 enum GfxColorSpaceMode
{
71 virtual ~GfxColorSpace();
72 virtual GfxColorSpace
*copy() = 0;
73 virtual GfxColorSpaceMode
getMode() = 0;
75 // Construct a color space. Returns NULL if unsuccessful.
76 static GfxColorSpace
*parse(Object
*csObj
);
78 // Convert to gray, RGB, or CMYK.
79 virtual void getGray(GfxColor
*color
, double *gray
) = 0;
80 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
) = 0;
81 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
) = 0;
83 // Return the number of color components.
84 virtual int getNComps() = 0;
86 // Return the default ranges for each component, assuming an image
87 // with a max pixel value of <maxImgPixel>.
88 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
94 //------------------------------------------------------------------------
95 // GfxDeviceGrayColorSpace
96 //------------------------------------------------------------------------
98 class GfxDeviceGrayColorSpace
: public GfxColorSpace
{
101 GfxDeviceGrayColorSpace();
102 virtual ~GfxDeviceGrayColorSpace();
103 virtual GfxColorSpace
*copy();
104 virtual GfxColorSpaceMode
getMode() { return csDeviceGray
; }
106 virtual void getGray(GfxColor
*color
, double *gray
);
107 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
108 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
110 virtual int getNComps() { return 1; }
115 //------------------------------------------------------------------------
116 // GfxCalGrayColorSpace
117 //------------------------------------------------------------------------
119 class GfxCalGrayColorSpace
: public GfxColorSpace
{
122 GfxCalGrayColorSpace();
123 virtual ~GfxCalGrayColorSpace();
124 virtual GfxColorSpace
*copy();
125 virtual GfxColorSpaceMode
getMode() { return csCalGray
; }
127 // Construct a CalGray color space. Returns NULL if unsuccessful.
128 static GfxColorSpace
*parse(Array
*arr
);
130 virtual void getGray(GfxColor
*color
, double *gray
);
131 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
132 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
134 virtual int getNComps() { return 1; }
136 // CalGray-specific access.
137 double getWhiteX() { return whiteX
; }
138 double getWhiteY() { return whiteY
; }
139 double getWhiteZ() { return whiteZ
; }
140 double getBlackX() { return blackX
; }
141 double getBlackY() { return blackY
; }
142 double getBlackZ() { return blackZ
; }
143 double getGamma() { return gamma
; }
147 double whiteX
, whiteY
, whiteZ
; // white point
148 double blackX
, blackY
, blackZ
; // black point
149 double gamma
; // gamma value
152 //------------------------------------------------------------------------
153 // GfxDeviceRGBColorSpace
154 //------------------------------------------------------------------------
156 class GfxDeviceRGBColorSpace
: public GfxColorSpace
{
159 GfxDeviceRGBColorSpace();
160 virtual ~GfxDeviceRGBColorSpace();
161 virtual GfxColorSpace
*copy();
162 virtual GfxColorSpaceMode
getMode() { return csDeviceRGB
; }
164 virtual void getGray(GfxColor
*color
, double *gray
);
165 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
166 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
168 virtual int getNComps() { return 3; }
173 //------------------------------------------------------------------------
174 // GfxCalRGBColorSpace
175 //------------------------------------------------------------------------
177 class GfxCalRGBColorSpace
: public GfxColorSpace
{
180 GfxCalRGBColorSpace();
181 virtual ~GfxCalRGBColorSpace();
182 virtual GfxColorSpace
*copy();
183 virtual GfxColorSpaceMode
getMode() { return csCalRGB
; }
185 // Construct a CalRGB color space. Returns NULL if unsuccessful.
186 static GfxColorSpace
*parse(Array
*arr
);
188 virtual void getGray(GfxColor
*color
, double *gray
);
189 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
190 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
192 virtual int getNComps() { return 3; }
194 // CalRGB-specific access.
195 double getWhiteX() { return whiteX
; }
196 double getWhiteY() { return whiteY
; }
197 double getWhiteZ() { return whiteZ
; }
198 double getBlackX() { return blackX
; }
199 double getBlackY() { return blackY
; }
200 double getBlackZ() { return blackZ
; }
201 double getGammaR() { return gammaR
; }
202 double getGammaG() { return gammaG
; }
203 double getGammaB() { return gammaB
; }
204 double *getMatrix() { return m
; }
208 double whiteX
, whiteY
, whiteZ
; // white point
209 double blackX
, blackY
, blackZ
; // black point
210 double gammaR
, gammaG
, gammaB
; // gamma values
211 double m
[9]; // ABC -> XYZ transform matrix
214 //------------------------------------------------------------------------
215 // GfxDeviceCMYKColorSpace
216 //------------------------------------------------------------------------
218 class GfxDeviceCMYKColorSpace
: public GfxColorSpace
{
221 GfxDeviceCMYKColorSpace();
222 virtual ~GfxDeviceCMYKColorSpace();
223 virtual GfxColorSpace
*copy();
224 virtual GfxColorSpaceMode
getMode() { return csDeviceCMYK
; }
226 virtual void getGray(GfxColor
*color
, double *gray
);
227 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
228 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
230 virtual int getNComps() { return 4; }
235 //------------------------------------------------------------------------
237 //------------------------------------------------------------------------
239 class GfxLabColorSpace
: public GfxColorSpace
{
243 virtual ~GfxLabColorSpace();
244 virtual GfxColorSpace
*copy();
245 virtual GfxColorSpaceMode
getMode() { return csLab
; }
247 // Construct a Lab color space. Returns NULL if unsuccessful.
248 static GfxColorSpace
*parse(Array
*arr
);
250 virtual void getGray(GfxColor
*color
, double *gray
);
251 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
252 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
254 virtual int getNComps() { return 3; }
256 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
259 // Lab-specific access.
260 double getWhiteX() { return whiteX
; }
261 double getWhiteY() { return whiteY
; }
262 double getWhiteZ() { return whiteZ
; }
263 double getBlackX() { return blackX
; }
264 double getBlackY() { return blackY
; }
265 double getBlackZ() { return blackZ
; }
266 double getAMin() { return aMin
; }
267 double getAMax() { return aMax
; }
268 double getBMin() { return bMin
; }
269 double getBMax() { return bMax
; }
273 double whiteX
, whiteY
, whiteZ
; // white point
274 double blackX
, blackY
, blackZ
; // black point
275 double aMin
, aMax
, bMin
, bMax
; // range for the a and b components
276 double kr
, kg
, kb
; // gamut mapping mulitpliers
279 //------------------------------------------------------------------------
280 // GfxICCBasedColorSpace
281 //------------------------------------------------------------------------
283 class GfxICCBasedColorSpace
: public GfxColorSpace
{
286 GfxICCBasedColorSpace(int nComps
, GfxColorSpace
*alt
,
287 Ref
*iccProfileStream
);
288 virtual ~GfxICCBasedColorSpace();
289 virtual GfxColorSpace
*copy();
290 virtual GfxColorSpaceMode
getMode() { return csICCBased
; }
292 // Construct an ICCBased color space. Returns NULL if unsuccessful.
293 static GfxColorSpace
*parse(Array
*arr
);
295 virtual void getGray(GfxColor
*color
, double *gray
);
296 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
297 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
299 virtual int getNComps() { return nComps
; }
301 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
304 // ICCBased-specific access.
305 GfxColorSpace
*getAlt() { return alt
; }
309 int nComps
; // number of color components (1, 3, or 4)
310 GfxColorSpace
*alt
; // alternate color space
311 double rangeMin
[4]; // min values for each component
312 double rangeMax
[4]; // max values for each component
313 Ref iccProfileStream
; // the ICC profile
316 //------------------------------------------------------------------------
317 // GfxIndexedColorSpace
318 //------------------------------------------------------------------------
320 class GfxIndexedColorSpace
: public GfxColorSpace
{
323 GfxIndexedColorSpace(GfxColorSpace
*base
, int indexHigh
);
324 virtual ~GfxIndexedColorSpace();
325 virtual GfxColorSpace
*copy();
326 virtual GfxColorSpaceMode
getMode() { return csIndexed
; }
328 // Construct a Lab color space. Returns NULL if unsuccessful.
329 static GfxColorSpace
*parse(Array
*arr
);
331 virtual void getGray(GfxColor
*color
, double *gray
);
332 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
333 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
335 virtual int getNComps() { return 1; }
337 virtual void getDefaultRanges(double *decodeLow
, double *decodeRange
,
340 // Indexed-specific access.
341 GfxColorSpace
*getBase() { return base
; }
342 int getIndexHigh() { return indexHigh
; }
343 Guchar
*getLookup() { return lookup
; }
347 GfxColorSpace
*base
; // base color space
348 int indexHigh
; // max pixel value
349 Guchar
*lookup
; // lookup table
352 //------------------------------------------------------------------------
353 // GfxSeparationColorSpace
354 //------------------------------------------------------------------------
356 class GfxSeparationColorSpace
: public GfxColorSpace
{
359 GfxSeparationColorSpace(GString
*name
, GfxColorSpace
*alt
,
361 virtual ~GfxSeparationColorSpace();
362 virtual GfxColorSpace
*copy();
363 virtual GfxColorSpaceMode
getMode() { return csSeparation
; }
365 // Construct a Separation color space. Returns NULL if unsuccessful.
366 static GfxColorSpace
*parse(Array
*arr
);
368 virtual void getGray(GfxColor
*color
, double *gray
);
369 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
370 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
372 virtual int getNComps() { return 1; }
374 // Separation-specific access.
375 GString
*getName() { return name
; }
376 GfxColorSpace
*getAlt() { return alt
; }
377 Function
*getFunc() { return func
; }
381 GString
*name
; // colorant name
382 GfxColorSpace
*alt
; // alternate color space
383 Function
*func
; // tint transform (into alternate color space)
386 //------------------------------------------------------------------------
387 // GfxDeviceNColorSpace
388 //------------------------------------------------------------------------
390 class GfxDeviceNColorSpace
: public GfxColorSpace
{
393 GfxDeviceNColorSpace(int nComps
, GfxColorSpace
*alt
, Function
*func
);
394 virtual ~GfxDeviceNColorSpace();
395 virtual GfxColorSpace
*copy();
396 virtual GfxColorSpaceMode
getMode() { return csDeviceN
; }
398 // Construct a DeviceN color space. Returns NULL if unsuccessful.
399 static GfxColorSpace
*parse(Array
*arr
);
401 virtual void getGray(GfxColor
*color
, double *gray
);
402 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
403 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
405 virtual int getNComps() { return nComps
; }
407 // DeviceN-specific access.
408 GfxColorSpace
*getAlt() { return alt
; }
412 int nComps
; // number of components
413 GString
// colorant names
414 *names
[gfxColorMaxComps
];
415 GfxColorSpace
*alt
; // alternate color space
416 Function
*func
; // tint transform (into alternate color space)
420 //------------------------------------------------------------------------
421 // GfxPatternColorSpace
422 //------------------------------------------------------------------------
424 class GfxPatternColorSpace
: public GfxColorSpace
{
427 GfxPatternColorSpace(GfxColorSpace
*under
);
428 virtual ~GfxPatternColorSpace();
429 virtual GfxColorSpace
*copy();
430 virtual GfxColorSpaceMode
getMode() { return csPattern
; }
432 // Construct a Pattern color space. Returns NULL if unsuccessful.
433 static GfxColorSpace
*parse(Array
*arr
);
435 virtual void getGray(GfxColor
*color
, double *gray
);
436 virtual void getRGB(GfxColor
*color
, GfxRGB
*rgb
);
437 virtual void getCMYK(GfxColor
*color
, GfxCMYK
*cmyk
);
439 virtual int getNComps() { return 0; }
441 // Pattern-specific access.
442 GfxColorSpace
*getUnder() { return under
; }
446 GfxColorSpace
*under
; // underlying color space (for uncolored
450 //------------------------------------------------------------------------
452 //------------------------------------------------------------------------
457 GfxPattern(int type
);
458 virtual ~GfxPattern();
460 static GfxPattern
*parse(Object
*obj
);
462 virtual GfxPattern
*copy() = 0;
464 int getType() { return type
; }
471 //------------------------------------------------------------------------
473 //------------------------------------------------------------------------
475 class GfxTilingPattern
: public GfxPattern
{
478 GfxTilingPattern(Dict
*streamDict
, Object
*stream
);
479 virtual ~GfxTilingPattern();
481 virtual GfxPattern
*copy();
483 int getPaintType() { return paintType
; }
484 int getTilingType() { return tilingType
; }
485 double *getBBox() { return bbox
; }
486 double getXStep() { return xStep
; }
487 double getYStep() { return yStep
; }
489 { return resDict
.isDict() ? resDict
.getDict() : (Dict
*)NULL
; }
490 double *getMatrix() { return matrix
; }
491 Object
*getContentStream() { return &contentStream
; }
495 GfxTilingPattern(GfxTilingPattern
*pat
);
503 Object contentStream
;
506 //------------------------------------------------------------------------
508 //------------------------------------------------------------------------
510 #define funcMaxInputs 1
511 #define funcMaxOutputs 8
520 // Construct a function. Returns NULL if unsuccessful.
521 static Function
*parse(Object
*funcObj
);
523 // Initialize the entries common to all function types.
524 GBool
init(Dict
*dict
);
526 virtual Function
*copy() = 0;
528 // Return size of input and output tuples.
529 int getInputSize() { return m
; }
530 int getOutputSize() { return n
; }
532 // Transform an input tuple into an output tuple.
533 virtual void transform(double *in
, double *out
) = 0;
535 virtual GBool
isOk() = 0;
539 int m
, n
; // size of input and output tuples
540 double // min and max values for function domain
541 domain
[funcMaxInputs
][2];
542 double // min and max values for function range
543 range
[funcMaxOutputs
][2];
544 GBool hasRange
; // set if range is defined
547 //------------------------------------------------------------------------
549 //------------------------------------------------------------------------
551 class SampledFunction
: public Function
{
554 SampledFunction(Object
*funcObj
, Dict
*dict
);
555 virtual ~SampledFunction();
556 virtual Function
*copy() { return new SampledFunction(this); }
557 virtual void transform(double *in
, double *out
);
558 virtual GBool
isOk() { return ok
; }
562 SampledFunction(SampledFunction
*func
);
564 int // number of samples for each domain element
565 sampleSize
[funcMaxInputs
];
566 double // min and max values for domain encoder
567 encode
[funcMaxInputs
][2];
568 double // min and max values for range decoder
569 decode
[funcMaxOutputs
][2];
570 double *samples
; // the samples
574 //------------------------------------------------------------------------
575 // ExponentialFunction
576 //------------------------------------------------------------------------
578 class ExponentialFunction
: public Function
{
581 ExponentialFunction(Object
*funcObj
, Dict
*dict
);
582 virtual ~ExponentialFunction();
583 virtual Function
*copy() { return new ExponentialFunction(this); }
584 virtual void transform(double *in
, double *out
);
585 virtual GBool
isOk() { return ok
; }
589 ExponentialFunction(ExponentialFunction
*func
);
591 double c0
[funcMaxOutputs
];
592 double c1
[funcMaxOutputs
];
597 //------------------------------------------------------------------------
599 //------------------------------------------------------------------------
601 class GfxImageColorMap
{
605 GfxImageColorMap(int bits
, Object
*decode
, GfxColorSpace
*colorSpace
);
610 // Is color map valid?
611 GBool
isOk() { return ok
; }
613 // Get the color space.
614 GfxColorSpace
*getColorSpace() { return colorSpace
; }
616 // Get stream decoding info.
617 int getNumPixelComps() { return nComps
; }
618 int getBits() { return bits
; }
621 double getDecodeLow(int i
) { return decodeLow
[i
]; }
622 double getDecodeHigh(int i
) { return decodeLow
[i
] + decodeRange
[i
]; }
624 // Convert an image pixel to a color.
625 void getGray(Guchar
*x
, double *gray
);
626 void getRGB(Guchar
*x
, GfxRGB
*rgb
);
627 void getCMYK(Guchar
*x
, GfxCMYK
*cmyk
);
631 GfxColorSpace
*colorSpace
; // the image color space
632 int bits
; // bits per component
633 int nComps
; // number of components in a pixel
634 GfxColorSpace
*colorSpace2
; // secondary color space
635 int nComps2
; // number of components in colorSpace2
636 double *lookup
; // lookup table
637 double // minimum values for each component
638 decodeLow
[gfxColorMaxComps
];
639 double // max - min value for each component
640 decodeRange
[gfxColorMaxComps
];
644 //------------------------------------------------------------------------
645 // GfxSubpath and GfxPath
646 //------------------------------------------------------------------------
652 GfxSubpath(double x1
, double y1
);
658 GfxSubpath
*copy() { return new GfxSubpath(this); }
661 int getNumPoints() { return n
; }
662 double getX(int i
) { return x
[i
]; }
663 double getY(int i
) { return y
[i
]; }
664 GBool
getCurve(int i
) { return curve
[i
]; }
667 double getLastX() { return x
[n
-1]; }
668 double getLastY() { return y
[n
-1]; }
670 // Add a line segment.
671 void lineTo(double x1
, double y1
);
673 // Add a Bezier curve.
674 void curveTo(double x1
, double y1
, double x2
, double y2
,
675 double x3
, double y3
);
677 // Close the subpath.
679 GBool
isClosed() { return closed
; }
683 double *x
, *y
; // points
684 GBool
*curve
; // curve[i] => point i is a control point
685 // for a Bezier curve
686 int n
; // number of points
687 int size
; // size of x/y arrays
688 GBool closed
; // set if path is closed
690 GfxSubpath(GfxSubpath
*subpath
);
704 { return new GfxPath(justMoved
, firstX
, firstY
, subpaths
, n
, size
); }
706 // Is there a current point?
707 GBool
isCurPt() { return n
> 0 || justMoved
; }
709 // Is the path non-empty, i.e., is there at least one segment?
710 GBool
isPath() { return n
> 0; }
713 int getNumSubpaths() { return n
; }
714 GfxSubpath
*getSubpath(int i
) { return subpaths
[i
]; }
716 // Get last point on last subpath.
717 double getLastX() { return subpaths
[n
-1]->getLastX(); }
718 double getLastY() { return subpaths
[n
-1]->getLastY(); }
720 // Move the current point.
721 void moveTo(double x
, double y
);
723 // Add a segment to the last subpath.
724 void lineTo(double x
, double y
);
726 // Add a Bezier curve to the last subpath
727 void curveTo(double x1
, double y1
, double x2
, double y2
,
728 double x3
, double y3
);
730 // Close the last subpath.
731 void close() { subpaths
[n
-1]->close(); }
735 GBool justMoved
; // set if a new subpath was just started
736 double firstX
, firstY
; // first point in new subpath
737 GfxSubpath
**subpaths
; // subpaths
738 int n
; // number of subpaths
739 int size
; // size of subpaths array
741 GfxPath(GBool justMoved1
, double firstX1
, double firstY1
,
742 GfxSubpath
**subpaths1
, int n1
, int size1
);
745 //------------------------------------------------------------------------
747 //------------------------------------------------------------------------
752 // Construct a default GfxState, for a device with resolution <dpi>,
753 // page box (<x1>,<y1>)-(<x2>,<y2>), page rotation <rotate>, and
754 // coordinate system specified by <upsideDown>.
755 GfxState(double dpi
, double px1a
, double py1a
,
756 double px2a
, double py2a
, int rotate
, GBool upsideDown
);
762 GfxState
*copy() { return new GfxState(this); }
765 double *getCTM() { return ctm
; }
766 double getX1() { return px1
; }
767 double getY1() { return py1
; }
768 double getX2() { return px2
; }
769 double getY2() { return py2
; }
770 double getPageWidth() { return pageWidth
; }
771 double getPageHeight() { return pageHeight
; }
772 GfxColor
*getFillColor() { return &fillColor
; }
773 GfxColor
*getStrokeColor() { return &strokeColor
; }
774 void getFillRGB(GfxRGB
*rgb
)
775 { fillColorSpace
->getRGB(&fillColor
, rgb
); }
776 void getStrokeRGB(GfxRGB
*rgb
)
777 { strokeColorSpace
->getRGB(&strokeColor
, rgb
); }
778 void getFillCMYK(GfxCMYK
*cmyk
)
779 { fillColorSpace
->getCMYK(&fillColor
, cmyk
); }
780 void getStrokeCMYK(GfxCMYK
*cmyk
)
781 { strokeColorSpace
->getCMYK(&strokeColor
, cmyk
); }
782 GfxColorSpace
*getFillColorSpace() { return fillColorSpace
; }
783 GfxColorSpace
*getStrokeColorSpace() { return strokeColorSpace
; }
784 GfxPattern
*getFillPattern() { return fillPattern
; }
785 GfxPattern
*getStrokePattern() { return strokePattern
; }
786 double getFillOpacity() { return fillOpacity
; }
787 double getStrokeOpacity() { return strokeOpacity
; }
788 double getLineWidth() { return lineWidth
; }
789 void getLineDash(double **dash
, int *length
, double *start
)
790 { *dash
= lineDash
; *length
= lineDashLength
; *start
= lineDashStart
; }
791 int getFlatness() { return flatness
; }
792 int getLineJoin() { return lineJoin
; }
793 int getLineCap() { return lineCap
; }
794 double getMiterLimit() { return miterLimit
; }
795 GfxFont
*getFont() { return font
; }
796 double getFontSize() { return fontSize
; }
797 double *getTextMat() { return textMat
; }
798 double getCharSpace() { return charSpace
; }
799 double getWordSpace() { return wordSpace
; }
800 double getHorizScaling() { return horizScaling
; }
801 double getLeading() { return leading
; }
802 double getRise() { return rise
; }
803 int getRender() { return render
; }
804 GfxPath
*getPath() { return path
; }
805 double getCurX() { return curX
; }
806 double getCurY() { return curY
; }
807 double getLineX() { return lineX
; }
808 double getLineY() { return lineY
; }
810 // Is there a current point/path?
811 GBool
isCurPt() { return path
->isCurPt(); }
812 GBool
isPath() { return path
->isPath(); }
815 void transform(double x1
, double y1
, double *x2
, double *y2
)
816 { *x2
= ctm
[0] * x1
+ ctm
[2] * y1
+ ctm
[4];
817 *y2
= ctm
[1] * x1
+ ctm
[3] * y1
+ ctm
[5]; }
818 void transformDelta(double x1
, double y1
, double *x2
, double *y2
)
819 { *x2
= ctm
[0] * x1
+ ctm
[2] * y1
;
820 *y2
= ctm
[1] * x1
+ ctm
[3] * y1
; }
821 void textTransform(double x1
, double y1
, double *x2
, double *y2
)
822 { *x2
= textMat
[0] * x1
+ textMat
[2] * y1
+ textMat
[4];
823 *y2
= textMat
[1] * x1
+ textMat
[3] * y1
+ textMat
[5]; }
824 void textTransformDelta(double x1
, double y1
, double *x2
, double *y2
)
825 { *x2
= textMat
[0] * x1
+ textMat
[2] * y1
;
826 *y2
= textMat
[1] * x1
+ textMat
[3] * y1
; }
827 double transformWidth(double w
);
828 double getTransformedLineWidth()
829 { return transformWidth(lineWidth
); }
830 double getTransformedFontSize();
831 void getFontTransMat(double *m11
, double *m12
, double *m21
, double *m22
);
833 // Change state parameters.
834 void setCTM(double a
, double b
, double c
,
835 double d
, double e
, double f
);
836 void concatCTM(double a
, double b
, double c
,
837 double d
, double e
, double f
);
838 void setFillColorSpace(GfxColorSpace
*colorSpace
);
839 void setStrokeColorSpace(GfxColorSpace
*colorSpace
);
840 void setFillColor(GfxColor
*color
) { fillColor
= *color
; }
841 void setStrokeColor(GfxColor
*color
) { strokeColor
= *color
; }
842 void setFillPattern(GfxPattern
*pattern
);
843 void setStrokePattern(GfxPattern
*pattern
);
844 void setFillOpacity(double opac
) { fillOpacity
= opac
; }
845 void setStrokeOpacity(double opac
) { strokeOpacity
= opac
; }
846 void setLineWidth(double width
) { lineWidth
= width
; }
847 void setLineDash(double *dash
, int length
, double start
);
848 void setFlatness(int flatness1
) { flatness
= flatness1
; }
849 void setLineJoin(int lineJoin1
) { lineJoin
= lineJoin1
; }
850 void setLineCap(int lineCap1
) { lineCap
= lineCap1
; }
851 void setMiterLimit(double miterLimit1
) { miterLimit
= miterLimit1
; }
852 void setFont(GfxFont
*font1
, double fontSize1
)
853 { font
= font1
; fontSize
= fontSize1
; }
854 void setTextMat(double a
, double b
, double c
,
855 double d
, double e
, double f
)
856 { textMat
[0] = a
; textMat
[1] = b
; textMat
[2] = c
;
857 textMat
[3] = d
; textMat
[4] = e
; textMat
[5] = f
; }
858 void setCharSpace(double space
)
859 { charSpace
= space
; }
860 void setWordSpace(double space
)
861 { wordSpace
= space
; }
862 void setHorizScaling(double scale
)
863 { horizScaling
= 0.01 * scale
; }
864 void setLeading(double leading1
)
865 { leading
= leading1
; }
866 void setRise(double rise1
)
868 void setRender(int render1
)
869 { render
= render1
; }
872 void moveTo(double x
, double y
)
873 { path
->moveTo(curX
= x
, curY
= y
); }
874 void lineTo(double x
, double y
)
875 { path
->lineTo(curX
= x
, curY
= y
); }
876 void curveTo(double x1
, double y1
, double x2
, double y2
,
877 double x3
, double y3
)
878 { path
->curveTo(x1
, y1
, x2
, y2
, curX
= x3
, curY
= y3
); }
880 { path
->close(); curX
= path
->getLastX(); curY
= path
->getLastY(); }
884 void textMoveTo(double tx
, double ty
)
885 { lineX
= tx
; lineY
= ty
; textTransform(tx
, ty
, &curX
, &curY
); }
886 void textShift(double tx
);
887 void textShift(double tx
, double ty
);
889 // Push/pop GfxState on/off stack.
892 GBool
hasSaves() { return saved
!= NULL
; }
896 double ctm
[6]; // coord transform matrix
897 double px1
, py1
, px2
, py2
; // page corners (user coords)
898 double pageWidth
, pageHeight
; // page size (pixels)
900 GfxColorSpace
*fillColorSpace
; // fill color space
901 GfxColorSpace
*strokeColorSpace
; // stroke color space
902 GfxColor fillColor
; // fill color
903 GfxColor strokeColor
; // stroke color
904 GfxPattern
*fillPattern
; // fill pattern
905 GfxPattern
*strokePattern
; // stroke pattern
906 double fillOpacity
; // fill opacity
907 double strokeOpacity
; // stroke opacity
909 double lineWidth
; // line width
910 double *lineDash
; // line dash
912 double lineDashStart
;
913 int flatness
; // curve flatness
914 int lineJoin
; // line join style
915 int lineCap
; // line cap style
916 double miterLimit
; // line miter limit
918 GfxFont
*font
; // font
919 double fontSize
; // font size
920 double textMat
[6]; // text matrix
921 double charSpace
; // character spacing
922 double wordSpace
; // word spacing
923 double horizScaling
; // horizontal scaling
924 double leading
; // text leading
925 double rise
; // text rise
926 int render
; // text rendering mode
928 GfxPath
*path
; // array of path elements
929 double curX
, curY
; // current point (user coords)
930 double lineX
, lineY
; // start of current text line (text coords)
932 GfxState
*saved
; // next GfxState on stack
934 GfxState(GfxState
*state
);