30#define gfxColorMaxComps funcMaxOutputs
33 double c[gfxColorMaxComps];
56enum GfxColorSpaceMode {
74 virtual ~GfxColorSpace();
75 virtual GfxColorSpace *copy() const = 0;
76 virtual GfxColorSpaceMode getMode() const = 0;
79 static GfxColorSpace *parse(Object *csObj);
82 virtual void getGray( const GfxColor *color, double *gray) const = 0;
83 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const = 0;
84 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const = 0;
87 virtual int getNComps() const = 0;
91 virtual void getDefaultRanges( double *decodeLow, double *decodeRange,
92 int maxImgPixel) const;
101class GfxDeviceGrayColorSpace: public GfxColorSpace {
104 GfxDeviceGrayColorSpace();
105 virtual ~GfxDeviceGrayColorSpace();
106 virtual GfxColorSpace *copy() const;
107 virtual GfxColorSpaceMode getMode() const { return csDeviceGray; }
109 virtual void getGray( const GfxColor *color, double *gray) const;
110 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
111 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
113 virtual int getNComps() const { return 1; }
122class GfxCalGrayColorSpace: public GfxColorSpace {
125 GfxCalGrayColorSpace();
126 virtual ~GfxCalGrayColorSpace();
127 virtual GfxColorSpace *copy() const;
128 virtual GfxColorSpaceMode getMode() const { return csCalGray; }
131 static GfxColorSpace *parse(Array *arr);
133 virtual void getGray( const GfxColor *color, double *gray) const;
134 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
135 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
137 virtual int getNComps() const { return 1; }
140 double getWhiteX() const { return whiteX; }
141 double getWhiteY() const { return whiteY; }
142 double getWhiteZ() const { return whiteZ; }
143 double getBlackX() const { return blackX; }
144 double getBlackY() const { return blackY; }
145 double getBlackZ() const { return blackZ; }
146 double getGamma() const { return gamma; }
150 double whiteX, whiteY, whiteZ;
151 double blackX, blackY, blackZ;
159class GfxDeviceRGBColorSpace: public GfxColorSpace {
162 GfxDeviceRGBColorSpace();
163 virtual ~GfxDeviceRGBColorSpace();
164 virtual GfxColorSpace *copy() const;
165 virtual GfxColorSpaceMode getMode() const { return csDeviceRGB; }
167 virtual void getGray( const GfxColor *color, double *gray) const;
168 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
169 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
171 virtual int getNComps() const{ return 3; }
180class GfxCalRGBColorSpace: public GfxColorSpace {
183 GfxCalRGBColorSpace();
184 virtual ~GfxCalRGBColorSpace();
185 virtual GfxColorSpace *copy() const;
186 virtual GfxColorSpaceMode getMode() const { return csCalRGB; }
189 static GfxColorSpace *parse(Array *arr);
191 virtual void getGray( const GfxColor *color, double *gray) const;
192 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
193 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
195 virtual int getNComps() const { return 3; }
198 double getWhiteX() const { return whiteX; }
199 double getWhiteY() const { return whiteY; }
200 double getWhiteZ() const { return whiteZ; }
201 double getBlackX() const { return blackX; }
202 double getBlackY() const { return blackY; }
203 double getBlackZ() const { return blackZ; }
204 double getGammaR() const { return gammaR; }
205 double getGammaG() const { return gammaG; }
206 double getGammaB() const { return gammaB; }
207 const double *getMatrix() const { return mat; }
211 double whiteX, whiteY, whiteZ;
212 double blackX, blackY, blackZ;
213 double gammaR, gammaG, gammaB;
221class GfxDeviceCMYKColorSpace: public GfxColorSpace {
224 GfxDeviceCMYKColorSpace();
225 virtual ~GfxDeviceCMYKColorSpace();
226 virtual GfxColorSpace *copy() const;
227 virtual GfxColorSpaceMode getMode() const { return csDeviceCMYK; }
229 virtual void getGray( const GfxColor *color, double *gray) const;
230 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
231 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
233 virtual int getNComps() const { return 4; }
242class GfxLabColorSpace: public GfxColorSpace {
246 virtual ~GfxLabColorSpace();
247 virtual GfxColorSpace *copy() const;
248 virtual GfxColorSpaceMode getMode() const { return csLab; }
251 static GfxColorSpace *parse(Array *arr);
253 virtual void getGray( const GfxColor *color, double *gray) const;
254 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
255 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
257 virtual int getNComps() const { return 3; }
259 virtual void getDefaultRanges( double *decodeLow, double *decodeRange,
260 int maxImgPixel) const;
263 double getWhiteX() const { return whiteX; }
264 double getWhiteY() const { return whiteY; }
265 double getWhiteZ() const { return whiteZ; }
266 double getBlackX() const { return blackX; }
267 double getBlackY() const { return blackY; }
268 double getBlackZ() const { return blackZ; }
269 double getAMin() const { return aMin; }
270 double getAMax() const { return aMax; }
271 double getBMin() const { return bMin; }
272 double getBMax() const { return bMax; }
276 double whiteX, whiteY, whiteZ;
277 double blackX, blackY, blackZ;
278 double aMin, aMax, bMin, bMax;
286class GfxICCBasedColorSpace: public GfxColorSpace {
289 GfxICCBasedColorSpace( int nCompsA, GfxColorSpace *altA,
290 const Ref *iccProfileStreamA);
291 virtual ~GfxICCBasedColorSpace();
292 virtual GfxColorSpace *copy() const;
293 virtual GfxColorSpaceMode getMode() const { return csICCBased; }
296 static GfxColorSpace *parse(Array *arr);
298 virtual void getGray( const GfxColor *color, double *gray) const;
299 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
300 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
302 virtual int getNComps() const { return nComps; }
304 virtual void getDefaultRanges( double *decodeLow, double *decodeRange,
305 int maxImgPixel) const;
308 const GfxColorSpace *getAlt() const { return alt; }
316 Ref iccProfileStream;
323class GfxIndexedColorSpace: public GfxColorSpace {
326 GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
327 virtual ~GfxIndexedColorSpace();
328 virtual GfxColorSpace *copy() const;
329 virtual GfxColorSpaceMode getMode() const { return csIndexed; }
332 static GfxColorSpace *parse(Array *arr);
334 virtual void getGray( const GfxColor *color, double *gray) const;
335 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
336 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
338 virtual int getNComps() const { return 1; }
340 virtual void getDefaultRanges( double *decodeLow, double *decodeRange,
341 int maxImgPixel) const;
344 const GfxColorSpace *getBase() const { return base; }
345 int getIndexHigh() const { return indexHigh; }
346 const Guchar *getLookup() const { return lookup; }
359class GfxSeparationColorSpace: public GfxColorSpace {
362 GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
364 virtual ~GfxSeparationColorSpace();
365 virtual GfxColorSpace *copy() const;
366 virtual GfxColorSpaceMode getMode() const { return csSeparation; }
369 static GfxColorSpace *parse(Array *arr);
371 virtual void getGray( const GfxColor *color, double *gray) const;
372 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
373 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
375 virtual int getNComps() const { return 1; }
378 const GString *getName() const { return name; }
379 const GfxColorSpace *getAlt() const { return alt; }
380 const Function *getFunc() const { return func; }
393class GfxDeviceNColorSpace: public GfxColorSpace {
396 GfxDeviceNColorSpace( int nComps, GfxColorSpace *alt, Function *func);
397 virtual ~GfxDeviceNColorSpace();
398 virtual GfxColorSpace *copy() const;
399 virtual GfxColorSpaceMode getMode() const { return csDeviceN; }
402 static GfxColorSpace *parse(Array *arr);
404 virtual void getGray( const GfxColor *color, double *gray) const;
405 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
406 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
408 virtual int getNComps() const { return nComps; }
411 const GString *getColorantName( int i) const { return names[i]; }
412 const GfxColorSpace *getAlt() const { return alt; }
413 const Function *getTintTransformFunc() const { return func; }
419 *names[gfxColorMaxComps];
429class GfxPatternColorSpace: public GfxColorSpace {
432 GfxPatternColorSpace(GfxColorSpace *underA);
433 virtual ~GfxPatternColorSpace();
434 virtual GfxColorSpace *copy() const;
435 virtual GfxColorSpaceMode getMode() const { return csPattern; }
438 static GfxColorSpace *parse(Array *arr);
440 virtual void getGray( const GfxColor *color, double *gray) const;
441 virtual void getRGB( const GfxColor *color, GfxRGB *rgb) const;
442 virtual void getCMYK( const GfxColor *color, GfxCMYK *cmyk) const;
444 virtual int getNComps() const { return 0; }
447 const GfxColorSpace *getUnder() const { return under; }
451 GfxColorSpace *under;
462 GfxPattern( int typeA);
463 virtual ~GfxPattern();
465 static GfxPattern *parse(Object *obj);
467 virtual GfxPattern *copy() = 0;
469 int getType() { return type; }
480class GfxTilingPattern: public GfxPattern {
483 GfxTilingPattern(Dict *streamDict, Object *stream);
484 virtual ~GfxTilingPattern();
486 virtual GfxPattern *copy();
488 int getPaintType() { return paintType; }
489 int getTilingType() { return tilingType; }
490 double *getBBox() { return bbox; }
491 double getXStep() { return xStep; }
492 double getYStep() { return yStep; }
494 { return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
495 double *getMatrix() { return matrix; }
496 Object *getContentStream() { return &contentStream; }
500 GfxTilingPattern(GfxTilingPattern *pat);
508 Object contentStream;
519 virtual ~GfxShading();
521 static GfxShading *parse(Object *obj);
523 int getType() { return type; }
524 GfxColorSpace *getColorSpace() { return colorSpace; }
525 GfxColor *getBackground() { return &background; }
526 GBool getHasBackground() { return hasBackground; }
527 void getBBox( double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
528 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
529 GBool getHasBBox() { return hasBBox; }
534 GfxColorSpace *colorSpace;
537 double xMin, yMin, xMax, yMax;
545class GfxAxialShading: public GfxShading {
548 GfxAxialShading( double x0A, double y0A,
549 double x1A, double y1A,
550 double t0A, double t1A,
551 Function **funcsA, int nFuncsA,
552 GBool extend0A, GBool extend1A);
553 virtual ~GfxAxialShading();
555 static GfxAxialShading *parse(Dict *dict);
557 void getCoords( double *x0A, double *y0A, double *x1A, double *y1A)
558 { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
559 double getDomain0() { return t0; }
560 double getDomain1() { return t1; }
561 void getColor( double t, GfxColor *color);
562 GBool getExtend0() { return extend0; }
563 GBool getExtend1() { return extend1; }
567 double x0, y0, x1, y1;
569 Function *funcs[gfxColorMaxComps];
571 GBool extend0, extend1;
578class GfxRadialShading: public GfxShading {
581 GfxRadialShading( double x0A, double y0A, double r0A,
582 double x1A, double y1A, double r1A,
583 double t0A, double t1A,
584 Function **funcsA, int nFuncsA,
585 GBool extend0A, GBool extend1A);
586 virtual ~GfxRadialShading();
588 static GfxRadialShading *parse(Dict *dict);
590 void getCoords( double *x0A, double *y0A, double *r0A,
591 double *x1A, double *y1A, double *r1A)
592 { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
593 double getDomain0() { return t0; }
594 double getDomain1() { return t1; }
595 void getColor( double t, GfxColor *color);
596 GBool getExtend0() { return extend0; }
597 GBool getExtend1() { return extend1; }
601 double x0, y0, r0, x1, y1, r1;
603 Function *funcs[gfxColorMaxComps];
605 GBool extend0, extend1;
612class GfxImageColorMap {
616 GfxImageColorMap( int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
622 GBool isOk() { return ok; }
625 GfxColorSpace *getColorSpace() { return colorSpace; }
628 int getNumPixelComps() { return nComps; }
629 int getBits() { return bits; }
632 double getDecodeLow( int i) { return decodeLow[i]; }
633 double getDecodeHigh( int i) { return decodeLow[i] + decodeRange[i]; }
636 void getGray(Guchar *x, double *gray);
637 void getRGB(Guchar *x, GfxRGB *rgb);
638 void getCMYK(Guchar *x, GfxCMYK *cmyk);
642 GfxColorSpace *colorSpace;
645 const GfxColorSpace *colorSpace2;
649 decodeLow[gfxColorMaxComps];
651 decodeRange[gfxColorMaxComps];
663 GfxSubpath( double x1, double y1);
669 GfxSubpath *copy() { return new GfxSubpath( this); }
672 int getNumPoints() { return n; }
673 double getX( int i) { return x[i]; }
674 double getY( int i) { return y[i]; }
675 GBool getCurve( int i) { return curve[i]; }
678 double getLastX() { return x[n-1]; }
679 double getLastY() { return y[n-1]; }
682 void lineTo( double x1, double y1);
685 void curveTo( double x1, double y1, double x2, double y2,
686 double x3, double y3);
690 GBool isClosed() { return closed; }
701 GfxSubpath(GfxSubpath *subpath);
715 { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
718 GBool isCurPt() { return n > 0 || justMoved; }
721 GBool isPath() { return n > 0; }
724 int getNumSubpaths() { return n; }
725 GfxSubpath *getSubpath( int i) { return subpaths[i]; }
728 double getLastX() { return subpaths[n-1]->getLastX(); }
729 double getLastY() { return subpaths[n-1]->getLastY(); }
732 void moveTo( double x, double y);
735 void lineTo( double x, double y);
738 void curveTo( double x1, double y1, double x2, double y2,
739 double x3, double y3);
747 double firstX, firstY;
748 GfxSubpath **subpaths;
752 GfxPath(GBool justMoved1, double firstX1, double firstY1,
753 GfxSubpath **subpaths1, int n1, int size1);
766 GfxState( double dpi, PDFRectangle *pageBox, int rotate,
773 GfxState *copy() const { return new GfxState( this); }
776 const double *getCTM() const { return ctm; }
777 double getX1() const { return px1; }
778 double getY1() const { return py1; }
779 double getX2() const { return px2; }
780 double getY2() const { return py2; }
781 double getPageWidth() const { return pageWidth; }
782 double getPageHeight() const { return pageHeight; }
783 const GfxColor *getFillColor() const { return &fillColor; }
784 const GfxColor *getStrokeColor() const { return &strokeColor; }
785 void getFillGray( double *gray) const
786 { fillColorSpace->getGray(&fillColor, gray); }
787 void getStrokeGray( double *gray) const
788 { strokeColorSpace->getGray(&fillColor, gray); }
789 void getFillRGB(GfxRGB *rgb) const
790 { fillColorSpace->getRGB(&fillColor, rgb); }
791 void getStrokeRGB(GfxRGB *rgb) const
792 { strokeColorSpace->getRGB(&strokeColor, rgb); }
793 void getFillCMYK(GfxCMYK *cmyk) const
794 { fillColorSpace->getCMYK(&fillColor, cmyk); }
795 void getStrokeCMYK(GfxCMYK *cmyk) const
796 { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
797 GfxColorSpace *getFillColorSpace() const { return fillColorSpace; }
798 GfxColorSpace *getStrokeColorSpace() const { return strokeColorSpace; }
799 GfxPattern *getFillPattern() const { return fillPattern; }
800 GfxPattern *getStrokePattern() const { return strokePattern; }
801 double getFillOpacity() const { return fillOpacity; }
802 double getStrokeOpacity() const { return strokeOpacity; }
803 double getLineWidth() const { return lineWidth; }
804 void getLineDash( double **dash, int *length, double *start) const
805 { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
806 int getFlatness() const { return flatness; }
807 int getLineJoin() const { return lineJoin; }
808 int getLineCap() const { return lineCap; }
809 double getMiterLimit() const { return miterLimit; }
810 GfxFont *getFont() const { return font; }
811 double getFontSize() const { return fontSize; }
812 const double *getTextMat() const { return textMat; }
813 double getCharSpace() const { return charSpace; }
814 double getWordSpace() const { return wordSpace; }
815 double getHorizScaling() const { return horizScaling; }
816 double getLeading() const { return leading; }
817 double getRise() const { return rise; }
818 int getRender() const { return render; }
819 GfxPath *getPath() const { return path; }
820 double getCurX() const { return curX; }
821 double getCurY() const { return curY; }
822 void getClipBBox( double *xMin, double *yMin, double *xMax, double *yMax) const
823 { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
824 void getUserClipBBox( double *xMin, double *yMin, double *xMax, double *yMax) const;
825 double getLineX() const { return lineX; }
826 double getLineY() const { return lineY; }
829 GBool isCurPt() const { return path->isCurPt(); }
830 GBool isPath() const { return path->isPath(); }
833 void transform( double x1, double y1, double *x2, double *y2)
834 { *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
835 *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
836 void transformDelta( double x1, double y1, double *x2, double *y2)
837 { *x2 = ctm[0] * x1 + ctm[2] * y1;
838 *y2 = ctm[1] * x1 + ctm[3] * y1; }
839 void textTransform( double x1, double y1, double *x2, double *y2)
840 { *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
841 *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
842 void textTransformDelta( double x1, double y1, double *x2, double *y2)
843 { *x2 = textMat[0] * x1 + textMat[2] * y1;
844 *y2 = textMat[1] * x1 + textMat[3] * y1; }
845 double transformWidth( double w);
846 double getTransformedLineWidth()
847 { return transformWidth(lineWidth); }
848 double getTransformedFontSize();
849 void getFontTransMat( double *m11, double *m12, double *m21, double *m22);
852 void setCTM( double a, double b, double c,
853 double d, double e, double f);
854 void concatCTM( double a, double b, double c,
855 double d, double e, double f);
856 void setFillColorSpace(GfxColorSpace *colorSpace);
857 void setStrokeColorSpace(GfxColorSpace *colorSpace);
858 void setFillColor(GfxColor *color) { fillColor = *color; }
859 void setStrokeColor(GfxColor *color) { strokeColor = *color; }
860 void setFillPattern(GfxPattern *pattern);
861 void setStrokePattern(GfxPattern *pattern);
862 void setFillOpacity( double opac) { fillOpacity = opac; }
863 void setStrokeOpacity( double opac) { strokeOpacity = opac; }
864 void setLineWidth( double width) { lineWidth = width; }
865 void setLineDash( double *dash, int length, double start);
866 void setFlatness( int flatness1) { flatness = flatness1; }
867 void setLineJoin( int lineJoin1) { lineJoin = lineJoin1; }
868 void setLineCap( int lineCap1) { lineCap = lineCap1; }
869 void setMiterLimit( double limit) { miterLimit = limit; }
870 void setFont(GfxFont *fontA, double fontSizeA)
871 { font = fontA; fontSize = fontSizeA; }
872 void setTextMat( double a, double b, double c,
873 double d, double e, double f)
874 { textMat[0] = a; textMat[1] = b; textMat[2] = c;
875 textMat[3] = d; textMat[4] = e; textMat[5] = f; }
876 void setCharSpace( double space)
877 { charSpace = space; }
878 void setWordSpace( double space)
879 { wordSpace = space; }
880 void setHorizScaling( double scale)
881 { horizScaling = 0.01 * scale; }
882 void setLeading( double leadingA)
883 { leading = leadingA; }
884 void setRise( double riseA)
886 void setRender( int renderA)
887 { render = renderA; }
890 void moveTo( double x, double y)
891 { path->moveTo(curX = x, curY = y); }
892 void lineTo( double x, double y)
893 { path->lineTo(curX = x, curY = y); }
894 void curveTo( double x1, double y1, double x2, double y2,
895 double x3, double y3)
896 { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
898 { path->close(); curX = path->getLastX(); curY = path->getLastY(); }
905 void textMoveTo( double tx, double ty)
906 { lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
907 void textShift( double tx, double ty);
908 void shift( double dx, double dy);
913 GBool hasSaves() { return saved != NULL; }
918 double px1, py1, px2, py2;
919 double pageWidth, pageHeight;
921 GfxColorSpace *fillColorSpace;
922 GfxColorSpace *strokeColorSpace;
924 GfxColor strokeColor;
925 GfxPattern *fillPattern;
926 GfxPattern *strokePattern;
928 double strokeOpacity;
933 double lineDashStart;
953 double clipXMin, clipYMin,
958 GfxState( const GfxState *state);
|