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