00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GFXSTATE_H
00010 #define GFXSTATE_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "gtypes.h"
00019 #include "Object.h"
00020 #include "Function.h"
00021
00022 class Array;
00023 class GfxFont;
00024 class PDFRectangle;
00025
00026
00027
00028
00029
00030 #define gfxColorMaxComps funcMaxOutputs
00031
00032 struct GfxColor {
00033 double c[gfxColorMaxComps];
00034 };
00035
00036
00037
00038
00039
00040 struct GfxRGB {
00041 double r, g, b;
00042 };
00043
00044
00045
00046
00047
00048 struct GfxCMYK {
00049 double c, m, y, k;
00050 };
00051
00052
00053
00054
00055
00056 enum GfxColorSpaceMode {
00057 csDeviceGray,
00058 csCalGray,
00059 csDeviceRGB,
00060 csCalRGB,
00061 csDeviceCMYK,
00062 csLab,
00063 csICCBased,
00064 csIndexed,
00065 csSeparation,
00066 csDeviceN,
00067 csPattern
00068 };
00069
00070 class GfxColorSpace {
00071 public:
00072
00073 GfxColorSpace();
00074 virtual ~GfxColorSpace();
00075 virtual GfxColorSpace *copy() const = 0;
00076 virtual GfxColorSpaceMode getMode() const = 0;
00077
00078
00079 static GfxColorSpace *parse(Object *csObj);
00080
00081
00082 virtual void getGray(const GfxColor *color, double *gray) const = 0;
00083 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const = 0;
00084 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const = 0;
00085
00086
00087 virtual int getNComps() const = 0;
00088
00089
00090
00091 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
00092 int maxImgPixel) const;
00093
00094 private:
00095 };
00096
00097
00098
00099
00100
00101 class GfxDeviceGrayColorSpace: public GfxColorSpace {
00102 public:
00103
00104 GfxDeviceGrayColorSpace();
00105 virtual ~GfxDeviceGrayColorSpace();
00106 virtual GfxColorSpace *copy() const;
00107 virtual GfxColorSpaceMode getMode() const { return csDeviceGray; }
00108
00109 virtual void getGray(const GfxColor *color, double *gray) const;
00110 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00111 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00112
00113 virtual int getNComps() const { return 1; }
00114
00115 private:
00116 };
00117
00118
00119
00120
00121
00122 class GfxCalGrayColorSpace: public GfxColorSpace {
00123 public:
00124
00125 GfxCalGrayColorSpace();
00126 virtual ~GfxCalGrayColorSpace();
00127 virtual GfxColorSpace *copy() const;
00128 virtual GfxColorSpaceMode getMode() const { return csCalGray; }
00129
00130
00131 static GfxColorSpace *parse(Array *arr);
00132
00133 virtual void getGray(const GfxColor *color, double *gray) const;
00134 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00135 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00136
00137 virtual int getNComps() const { return 1; }
00138
00139
00140 double getWhiteX() const { return whiteX; }
00141 double getWhiteY() const { return whiteY; }
00142 double getWhiteZ() const { return whiteZ; }
00143 double getBlackX() const { return blackX; }
00144 double getBlackY() const { return blackY; }
00145 double getBlackZ() const { return blackZ; }
00146 double getGamma() const { return gamma; }
00147
00148 private:
00149
00150 double whiteX, whiteY, whiteZ;
00151 double blackX, blackY, blackZ;
00152 double gamma;
00153 };
00154
00155
00156
00157
00158
00159 class GfxDeviceRGBColorSpace: public GfxColorSpace {
00160 public:
00161
00162 GfxDeviceRGBColorSpace();
00163 virtual ~GfxDeviceRGBColorSpace();
00164 virtual GfxColorSpace *copy() const;
00165 virtual GfxColorSpaceMode getMode() const { return csDeviceRGB; }
00166
00167 virtual void getGray(const GfxColor *color, double *gray) const;
00168 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00169 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00170
00171 virtual int getNComps() const{ return 3; }
00172
00173 private:
00174 };
00175
00176
00177
00178
00179
00180 class GfxCalRGBColorSpace: public GfxColorSpace {
00181 public:
00182
00183 GfxCalRGBColorSpace();
00184 virtual ~GfxCalRGBColorSpace();
00185 virtual GfxColorSpace *copy() const;
00186 virtual GfxColorSpaceMode getMode() const { return csCalRGB; }
00187
00188
00189 static GfxColorSpace *parse(Array *arr);
00190
00191 virtual void getGray(const GfxColor *color, double *gray) const;
00192 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00193 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00194
00195 virtual int getNComps() const { return 3; }
00196
00197
00198 double getWhiteX() const { return whiteX; }
00199 double getWhiteY() const { return whiteY; }
00200 double getWhiteZ() const { return whiteZ; }
00201 double getBlackX() const { return blackX; }
00202 double getBlackY() const { return blackY; }
00203 double getBlackZ() const { return blackZ; }
00204 double getGammaR() const { return gammaR; }
00205 double getGammaG() const { return gammaG; }
00206 double getGammaB() const { return gammaB; }
00207 const double *getMatrix() const { return mat; }
00208
00209 private:
00210
00211 double whiteX, whiteY, whiteZ;
00212 double blackX, blackY, blackZ;
00213 double gammaR, gammaG, gammaB;
00214 double mat[9];
00215 };
00216
00217
00218
00219
00220
00221 class GfxDeviceCMYKColorSpace: public GfxColorSpace {
00222 public:
00223
00224 GfxDeviceCMYKColorSpace();
00225 virtual ~GfxDeviceCMYKColorSpace();
00226 virtual GfxColorSpace *copy() const;
00227 virtual GfxColorSpaceMode getMode() const { return csDeviceCMYK; }
00228
00229 virtual void getGray(const GfxColor *color, double *gray) const;
00230 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00231 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00232
00233 virtual int getNComps() const { return 4; }
00234
00235 private:
00236 };
00237
00238
00239
00240
00241
00242 class GfxLabColorSpace: public GfxColorSpace {
00243 public:
00244
00245 GfxLabColorSpace();
00246 virtual ~GfxLabColorSpace();
00247 virtual GfxColorSpace *copy() const;
00248 virtual GfxColorSpaceMode getMode() const { return csLab; }
00249
00250
00251 static GfxColorSpace *parse(Array *arr);
00252
00253 virtual void getGray(const GfxColor *color, double *gray) const;
00254 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00255 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00256
00257 virtual int getNComps() const { return 3; }
00258
00259 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
00260 int maxImgPixel) const;
00261
00262
00263 double getWhiteX() const { return whiteX; }
00264 double getWhiteY() const { return whiteY; }
00265 double getWhiteZ() const { return whiteZ; }
00266 double getBlackX() const { return blackX; }
00267 double getBlackY() const { return blackY; }
00268 double getBlackZ() const { return blackZ; }
00269 double getAMin() const { return aMin; }
00270 double getAMax() const { return aMax; }
00271 double getBMin() const { return bMin; }
00272 double getBMax() const { return bMax; }
00273
00274 private:
00275
00276 double whiteX, whiteY, whiteZ;
00277 double blackX, blackY, blackZ;
00278 double aMin, aMax, bMin, bMax;
00279 double kr, kg, kb;
00280 };
00281
00282
00283
00284
00285
00286 class GfxICCBasedColorSpace: public GfxColorSpace {
00287 public:
00288
00289 GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
00290 const Ref *iccProfileStreamA);
00291 virtual ~GfxICCBasedColorSpace();
00292 virtual GfxColorSpace *copy() const;
00293 virtual GfxColorSpaceMode getMode() const { return csICCBased; }
00294
00295
00296 static GfxColorSpace *parse(Array *arr);
00297
00298 virtual void getGray(const GfxColor *color, double *gray) const;
00299 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00300 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00301
00302 virtual int getNComps() const { return nComps; }
00303
00304 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
00305 int maxImgPixel) const;
00306
00307
00308 const GfxColorSpace *getAlt() const { return alt; }
00309
00310 private:
00311
00312 int nComps;
00313 GfxColorSpace *alt;
00314 double rangeMin[4];
00315 double rangeMax[4];
00316 Ref iccProfileStream;
00317 };
00318
00319
00320
00321
00322
00323 class GfxIndexedColorSpace: public GfxColorSpace {
00324 public:
00325
00326 GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
00327 virtual ~GfxIndexedColorSpace();
00328 virtual GfxColorSpace *copy() const;
00329 virtual GfxColorSpaceMode getMode() const { return csIndexed; }
00330
00331
00332 static GfxColorSpace *parse(Array *arr);
00333
00334 virtual void getGray(const GfxColor *color, double *gray) const;
00335 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00336 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00337
00338 virtual int getNComps() const { return 1; }
00339
00340 virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
00341 int maxImgPixel) const;
00342
00343
00344 const GfxColorSpace *getBase() const { return base; }
00345 int getIndexHigh() const { return indexHigh; }
00346 const Guchar *getLookup() const { return lookup; }
00347
00348 private:
00349
00350 GfxColorSpace *base;
00351 int indexHigh;
00352 Guchar *lookup;
00353 };
00354
00355
00356
00357
00358
00359 class GfxSeparationColorSpace: public GfxColorSpace {
00360 public:
00361
00362 GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
00363 Function *funcA);
00364 virtual ~GfxSeparationColorSpace();
00365 virtual GfxColorSpace *copy() const;
00366 virtual GfxColorSpaceMode getMode() const { return csSeparation; }
00367
00368
00369 static GfxColorSpace *parse(Array *arr);
00370
00371 virtual void getGray(const GfxColor *color, double *gray) const;
00372 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00373 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00374
00375 virtual int getNComps() const { return 1; }
00376
00377
00378 const GString *getName() const { return name; }
00379 const GfxColorSpace *getAlt() const { return alt; }
00380 const Function *getFunc() const { return func; }
00381
00382 private:
00383
00384 GString *name;
00385 GfxColorSpace *alt;
00386 Function *func;
00387 };
00388
00389
00390
00391
00392
00393 class GfxDeviceNColorSpace: public GfxColorSpace {
00394 public:
00395
00396 GfxDeviceNColorSpace(int nComps, GfxColorSpace *alt, Function *func);
00397 virtual ~GfxDeviceNColorSpace();
00398 virtual GfxColorSpace *copy() const;
00399 virtual GfxColorSpaceMode getMode() const { return csDeviceN; }
00400
00401
00402 static GfxColorSpace *parse(Array *arr);
00403
00404 virtual void getGray(const GfxColor *color, double *gray) const;
00405 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00406 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00407
00408 virtual int getNComps() const { return nComps; }
00409
00410
00411 const GString *getColorantName(int i) const { return names[i]; }
00412 const GfxColorSpace *getAlt() const { return alt; }
00413 const Function *getTintTransformFunc() const { return func; }
00414
00415 private:
00416
00417 int nComps;
00418 GString
00419 *names[gfxColorMaxComps];
00420 GfxColorSpace *alt;
00421 Function *func;
00422
00423 };
00424
00425
00426
00427
00428
00429 class GfxPatternColorSpace: public GfxColorSpace {
00430 public:
00431
00432 GfxPatternColorSpace(GfxColorSpace *underA);
00433 virtual ~GfxPatternColorSpace();
00434 virtual GfxColorSpace *copy() const;
00435 virtual GfxColorSpaceMode getMode() const { return csPattern; }
00436
00437
00438 static GfxColorSpace *parse(Array *arr);
00439
00440 virtual void getGray(const GfxColor *color, double *gray) const;
00441 virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const;
00442 virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const;
00443
00444 virtual int getNComps() const { return 0; }
00445
00446
00447 const GfxColorSpace *getUnder() const { return under; }
00448
00449 private:
00450
00451 GfxColorSpace *under;
00452
00453 };
00454
00455
00456
00457
00458
00459 class GfxPattern {
00460 public:
00461
00462 GfxPattern(int typeA);
00463 virtual ~GfxPattern();
00464
00465 static GfxPattern *parse(Object *obj);
00466
00467 virtual GfxPattern *copy() = 0;
00468
00469 int getType() { return type; }
00470
00471 private:
00472
00473 int type;
00474 };
00475
00476
00477
00478
00479
00480 class GfxTilingPattern: public GfxPattern {
00481 public:
00482
00483 GfxTilingPattern(Dict *streamDict, Object *stream);
00484 virtual ~GfxTilingPattern();
00485
00486 virtual GfxPattern *copy();
00487
00488 int getPaintType() { return paintType; }
00489 int getTilingType() { return tilingType; }
00490 double *getBBox() { return bbox; }
00491 double getXStep() { return xStep; }
00492 double getYStep() { return yStep; }
00493 Dict *getResDict()
00494 { return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
00495 double *getMatrix() { return matrix; }
00496 Object *getContentStream() { return &contentStream; }
00497
00498 private:
00499
00500 GfxTilingPattern(GfxTilingPattern *pat);
00501
00502 int paintType;
00503 int tilingType;
00504 double bbox[4];
00505 double xStep, yStep;
00506 Object resDict;
00507 double matrix[6];
00508 Object contentStream;
00509 };
00510
00511
00512
00513
00514
00515 class GfxShading {
00516 public:
00517
00518 GfxShading();
00519 virtual ~GfxShading();
00520
00521 static GfxShading *parse(Object *obj);
00522
00523 int getType() { return type; }
00524 GfxColorSpace *getColorSpace() { return colorSpace; }
00525 GfxColor *getBackground() { return &background; }
00526 GBool getHasBackground() { return hasBackground; }
00527 void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
00528 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
00529 GBool getHasBBox() { return hasBBox; }
00530
00531 private:
00532
00533 int type;
00534 GfxColorSpace *colorSpace;
00535 GfxColor background;
00536 GBool hasBackground;
00537 double xMin, yMin, xMax, yMax;
00538 GBool hasBBox;
00539 };
00540
00541
00542
00543
00544
00545 class GfxAxialShading: public GfxShading {
00546 public:
00547
00548 GfxAxialShading(double x0A, double y0A,
00549 double x1A, double y1A,
00550 double t0A, double t1A,
00551 Function **funcsA, int nFuncsA,
00552 GBool extend0A, GBool extend1A);
00553 virtual ~GfxAxialShading();
00554
00555 static GfxAxialShading *parse(Dict *dict);
00556
00557 void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
00558 { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
00559 double getDomain0() { return t0; }
00560 double getDomain1() { return t1; }
00561 void getColor(double t, GfxColor *color);
00562 GBool getExtend0() { return extend0; }
00563 GBool getExtend1() { return extend1; }
00564
00565 private:
00566
00567 double x0, y0, x1, y1;
00568 double t0, t1;
00569 Function *funcs[gfxColorMaxComps];
00570 int nFuncs;
00571 GBool extend0, extend1;
00572 };
00573
00574
00575
00576
00577
00578 class GfxRadialShading: public GfxShading {
00579 public:
00580
00581 GfxRadialShading(double x0A, double y0A, double r0A,
00582 double x1A, double y1A, double r1A,
00583 double t0A, double t1A,
00584 Function **funcsA, int nFuncsA,
00585 GBool extend0A, GBool extend1A);
00586 virtual ~GfxRadialShading();
00587
00588 static GfxRadialShading *parse(Dict *dict);
00589
00590 void getCoords(double *x0A, double *y0A, double *r0A,
00591 double *x1A, double *y1A, double *r1A)
00592 { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
00593 double getDomain0() { return t0; }
00594 double getDomain1() { return t1; }
00595 void getColor(double t, GfxColor *color);
00596 GBool getExtend0() { return extend0; }
00597 GBool getExtend1() { return extend1; }
00598
00599 private:
00600
00601 double x0, y0, r0, x1, y1, r1;
00602 double t0, t1;
00603 Function *funcs[gfxColorMaxComps];
00604 int nFuncs;
00605 GBool extend0, extend1;
00606 };
00607
00608
00609
00610
00611
00612 class GfxImageColorMap {
00613 public:
00614
00615
00616 GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
00617
00618
00619 ~GfxImageColorMap();
00620
00621
00622 GBool isOk() { return ok; }
00623
00624
00625 GfxColorSpace *getColorSpace() { return colorSpace; }
00626
00627
00628 int getNumPixelComps() { return nComps; }
00629 int getBits() { return bits; }
00630
00631
00632 double getDecodeLow(int i) { return decodeLow[i]; }
00633 double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
00634
00635
00636 void getGray(Guchar *x, double *gray);
00637 void getRGB(Guchar *x, GfxRGB *rgb);
00638 void getCMYK(Guchar *x, GfxCMYK *cmyk);
00639
00640 private:
00641
00642 GfxColorSpace *colorSpace;
00643 int bits;
00644 int nComps;
00645 const GfxColorSpace *colorSpace2;
00646 int nComps2;
00647 double *lookup;
00648 double
00649 decodeLow[gfxColorMaxComps];
00650 double
00651 decodeRange[gfxColorMaxComps];
00652 GBool ok;
00653 };
00654
00655
00656
00657
00658
00659 class GfxSubpath {
00660 public:
00661
00662
00663 GfxSubpath(double x1, double y1);
00664
00665
00666 ~GfxSubpath();
00667
00668
00669 GfxSubpath *copy() { return new GfxSubpath(this); }
00670
00671
00672 int getNumPoints() { return n; }
00673 double getX(int i) { return x[i]; }
00674 double getY(int i) { return y[i]; }
00675 GBool getCurve(int i) { return curve[i]; }
00676
00677
00678 double getLastX() { return x[n-1]; }
00679 double getLastY() { return y[n-1]; }
00680
00681
00682 void lineTo(double x1, double y1);
00683
00684
00685 void curveTo(double x1, double y1, double x2, double y2,
00686 double x3, double y3);
00687
00688
00689 void close();
00690 GBool isClosed() { return closed; }
00691
00692 private:
00693
00694 double *x, *y;
00695 GBool *curve;
00696
00697 int n;
00698 int size;
00699 GBool closed;
00700
00701 GfxSubpath(GfxSubpath *subpath);
00702 };
00703
00704 class GfxPath {
00705 public:
00706
00707
00708 GfxPath();
00709
00710
00711 ~GfxPath();
00712
00713
00714 GfxPath *copy()
00715 { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
00716
00717
00718 GBool isCurPt() { return n > 0 || justMoved; }
00719
00720
00721 GBool isPath() { return n > 0; }
00722
00723
00724 int getNumSubpaths() { return n; }
00725 GfxSubpath *getSubpath(int i) { return subpaths[i]; }
00726
00727
00728 double getLastX() { return subpaths[n-1]->getLastX(); }
00729 double getLastY() { return subpaths[n-1]->getLastY(); }
00730
00731
00732 void moveTo(double x, double y);
00733
00734
00735 void lineTo(double x, double y);
00736
00737
00738 void curveTo(double x1, double y1, double x2, double y2,
00739 double x3, double y3);
00740
00741
00742 void close();
00743
00744 private:
00745
00746 GBool justMoved;
00747 double firstX, firstY;
00748 GfxSubpath **subpaths;
00749 int n;
00750 int size;
00751
00752 GfxPath(GBool justMoved1, double firstX1, double firstY1,
00753 GfxSubpath **subpaths1, int n1, int size1);
00754 };
00755
00756
00757
00758
00759
00760 class GfxState {
00761 public:
00762
00763
00764
00765
00766 GfxState(double dpi, PDFRectangle *pageBox, int rotate,
00767 GBool upsideDown);
00768
00769
00770 ~GfxState();
00771
00772
00773 GfxState *copy() const { return new GfxState(this); }
00774
00775
00776 const double *getCTM() const { return ctm; }
00777 double getX1() const { return px1; }
00778 double getY1() const { return py1; }
00779 double getX2() const { return px2; }
00780 double getY2() const { return py2; }
00781 double getPageWidth() const { return pageWidth; }
00782 double getPageHeight() const { return pageHeight; }
00783 const GfxColor *getFillColor() const { return &fillColor; }
00784 const GfxColor *getStrokeColor() const { return &strokeColor; }
00785 void getFillGray(double *gray) const
00786 { fillColorSpace->getGray(&fillColor, gray); }
00787 void getStrokeGray(double *gray) const
00788 { strokeColorSpace->getGray(&fillColor, gray); }
00789 void getFillRGB(GfxRGB *rgb) const
00790 { fillColorSpace->getRGB(&fillColor, rgb); }
00791 void getStrokeRGB(GfxRGB *rgb) const
00792 { strokeColorSpace->getRGB(&strokeColor, rgb); }
00793 void getFillCMYK(GfxCMYK *cmyk) const
00794 { fillColorSpace->getCMYK(&fillColor, cmyk); }
00795 void getStrokeCMYK(GfxCMYK *cmyk) const
00796 { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
00797 GfxColorSpace *getFillColorSpace() const { return fillColorSpace; }
00798 GfxColorSpace *getStrokeColorSpace() const { return strokeColorSpace; }
00799 GfxPattern *getFillPattern() const { return fillPattern; }
00800 GfxPattern *getStrokePattern() const { return strokePattern; }
00801 double getFillOpacity() const { return fillOpacity; }
00802 double getStrokeOpacity() const { return strokeOpacity; }
00803 double getLineWidth() const { return lineWidth; }
00804 void getLineDash(double **dash, int *length, double *start) const
00805 { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
00806 int getFlatness() const { return flatness; }
00807 int getLineJoin() const { return lineJoin; }
00808 int getLineCap() const { return lineCap; }
00809 double getMiterLimit() const { return miterLimit; }
00810 GfxFont *getFont() const { return font; }
00811 double getFontSize() const { return fontSize; }
00812 const double *getTextMat() const { return textMat; }
00813 double getCharSpace() const { return charSpace; }
00814 double getWordSpace() const { return wordSpace; }
00815 double getHorizScaling() const { return horizScaling; }
00816 double getLeading() const { return leading; }
00817 double getRise() const { return rise; }
00818 int getRender() const { return render; }
00819 GfxPath *getPath() const { return path; }
00820 double getCurX() const { return curX; }
00821 double getCurY() const { return curY; }
00822 void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const
00823 { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
00824 void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const;
00825 double getLineX() const { return lineX; }
00826 double getLineY() const { return lineY; }
00827
00828
00829 GBool isCurPt() const { return path->isCurPt(); }
00830 GBool isPath() const { return path->isPath(); }
00831
00832
00833 void transform(double x1, double y1, double *x2, double *y2)
00834 { *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
00835 *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
00836 void transformDelta(double x1, double y1, double *x2, double *y2)
00837 { *x2 = ctm[0] * x1 + ctm[2] * y1;
00838 *y2 = ctm[1] * x1 + ctm[3] * y1; }
00839 void textTransform(double x1, double y1, double *x2, double *y2)
00840 { *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
00841 *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
00842 void textTransformDelta(double x1, double y1, double *x2, double *y2)
00843 { *x2 = textMat[0] * x1 + textMat[2] * y1;
00844 *y2 = textMat[1] * x1 + textMat[3] * y1; }
00845 double transformWidth(double w);
00846 double getTransformedLineWidth()
00847 { return transformWidth(lineWidth); }
00848 double getTransformedFontSize();
00849 void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
00850
00851
00852 void setCTM(double a, double b, double c,
00853 double d, double e, double f);
00854 void concatCTM(double a, double b, double c,
00855 double d, double e, double f);
00856 void setFillColorSpace(GfxColorSpace *colorSpace);
00857 void setStrokeColorSpace(GfxColorSpace *colorSpace);
00858 void setFillColor(GfxColor *color) { fillColor = *color; }
00859 void setStrokeColor(GfxColor *color) { strokeColor = *color; }
00860 void setFillPattern(GfxPattern *pattern);
00861 void setStrokePattern(GfxPattern *pattern);
00862 void setFillOpacity(double opac) { fillOpacity = opac; }
00863 void setStrokeOpacity(double opac) { strokeOpacity = opac; }
00864 void setLineWidth(double width) { lineWidth = width; }
00865 void setLineDash(double *dash, int length, double start);
00866 void setFlatness(int flatness1) { flatness = flatness1; }
00867 void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
00868 void setLineCap(int lineCap1) { lineCap = lineCap1; }
00869 void setMiterLimit(double limit) { miterLimit = limit; }
00870 void setFont(GfxFont *fontA, double fontSizeA)
00871 { font = fontA; fontSize = fontSizeA; }
00872 void setTextMat(double a, double b, double c,
00873 double d, double e, double f)
00874 { textMat[0] = a; textMat[1] = b; textMat[2] = c;
00875 textMat[3] = d; textMat[4] = e; textMat[5] = f; }
00876 void setCharSpace(double space)
00877 { charSpace = space; }
00878 void setWordSpace(double space)
00879 { wordSpace = space; }
00880 void setHorizScaling(double scale)
00881 { horizScaling = 0.01 * scale; }
00882 void setLeading(double leadingA)
00883 { leading = leadingA; }
00884 void setRise(double riseA)
00885 { rise = riseA; }
00886 void setRender(int renderA)
00887 { render = renderA; }
00888
00889
00890 void moveTo(double x, double y)
00891 { path->moveTo(curX = x, curY = y); }
00892 void lineTo(double x, double y)
00893 { path->lineTo(curX = x, curY = y); }
00894 void curveTo(double x1, double y1, double x2, double y2,
00895 double x3, double y3)
00896 { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
00897 void closePath()
00898 { path->close(); curX = path->getLastX(); curY = path->getLastY(); }
00899 void clearPath();
00900
00901
00902 void clip();
00903
00904
00905 void textMoveTo(double tx, double ty)
00906 { lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
00907 void textShift(double tx, double ty);
00908 void shift(double dx, double dy);
00909
00910
00911 GfxState *save();
00912 GfxState *restore();
00913 GBool hasSaves() { return saved != NULL; }
00914
00915 private:
00916
00917 double ctm[6];
00918 double px1, py1, px2, py2;
00919 double pageWidth, pageHeight;
00920
00921 GfxColorSpace *fillColorSpace;
00922 GfxColorSpace *strokeColorSpace;
00923 GfxColor fillColor;
00924 GfxColor strokeColor;
00925 GfxPattern *fillPattern;
00926 GfxPattern *strokePattern;
00927 double fillOpacity;
00928 double strokeOpacity;
00929
00930 double lineWidth;
00931 double *lineDash;
00932 int lineDashLength;
00933 double lineDashStart;
00934 int flatness;
00935 int lineJoin;
00936 int lineCap;
00937 double miterLimit;
00938
00939 GfxFont *font;
00940 double fontSize;
00941 double textMat[6];
00942 double charSpace;
00943 double wordSpace;
00944 double horizScaling;
00945 double leading;
00946 double rise;
00947 int render;
00948
00949 GfxPath *path;
00950 double curX, curY;
00951 double lineX, lineY;
00952
00953 double clipXMin, clipYMin,
00954 clipXMax, clipYMax;
00955
00956 GfxState *saved;
00957
00958 GfxState(const GfxState *state);
00959 };
00960
00961 #endif