added new output devices
[swftools.git] / lib / pdf / BitmapOutputDev.h
1 /* BitmapOutputDev.cc
2    Output device which creates a bitmap.
3
4    This file is part of swftools.
5
6    Swftools is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    Swftools is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with swftools; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
20 #ifndef __BitmapOutputDev_h__
21 #define __BitmapOutputDev_h__
22
23 #include "../gfxdevice.h"
24 #include "../gfxsource.h"
25 #include "../gfxtools.h"
26
27 #include "config.h"
28 #include "GFXOutputDev.h"
29 #include "InfoOutputDev.h"
30 #include "PDFDoc.h"
31 #include "CommonOutputDev.h"
32
33 class BitmapOutputDev: public CommonOutputDev {
34 public:
35     BitmapOutputDev(InfoOutputDev*info, PDFDoc*doc);
36     virtual ~BitmapOutputDev();
37    
38     // CommonOutputDev:
39     virtual void setDevice(gfxdevice_t*dev);
40     virtual void setMove(int x,int y);
41     virtual void setClip(int x1,int y1,int x2,int y2);
42     virtual void setParameter(const char*key, const char*value);
43     virtual void preparePage(int pdfpage, int outputpage);
44
45     // OutputDev:
46     virtual GBool upsideDown();
47     virtual GBool useDrawChar();
48     virtual GBool useTilingPatternFill();
49     virtual GBool useShadedFills();
50     virtual GBool useDrawForm();
51     virtual GBool interpretType3Chars();
52     virtual GBool needNonText();
53     virtual void setDefaultCTM(double *ctm);
54 /*    virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI,
55                                int rotate, GBool useMediaBox, GBool crop,
56                                int sliceX, int sliceY, int sliceW, int sliceH,
57                                GBool printing, Catalog *catalog,
58                                GBool (*abortCheckCbk)(void *data) = NULL,
59                                void *abortCheckCbkData = NULL);*/
60
61     virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
62     virtual void endPage();
63
64     virtual void saveState(GfxState *state);
65     virtual void restoreState(GfxState *state);
66
67     virtual void updateAll(GfxState *state);
68     virtual void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32);
69     virtual void updateLineDash(GfxState *state);
70     virtual void updateFlatness(GfxState *state);
71     virtual void updateLineJoin(GfxState *state);
72     virtual void updateLineCap(GfxState *state);
73     virtual void updateMiterLimit(GfxState *state);
74     virtual void updateLineWidth(GfxState *state);
75     virtual void updateStrokeAdjust(GfxState *state);
76     virtual void updateFillColorSpace(GfxState *state);
77     virtual void updateStrokeColorSpace(GfxState *state);
78     virtual void updateFillColor(GfxState *state);
79     virtual void updateStrokeColor(GfxState *state);
80     virtual void updateBlendMode(GfxState *state);
81     virtual void updateFillOpacity(GfxState *state);
82     virtual void updateStrokeOpacity(GfxState *state);
83     virtual void updateFillOverprint(GfxState *state);
84     virtual void updateStrokeOverprint(GfxState *state);
85     virtual void updateTransfer(GfxState *state);
86     virtual void updateFont(GfxState *state);
87     virtual void updateTextMat(GfxState *state);
88     virtual void updateCharSpace(GfxState *state);
89     virtual void updateRender(GfxState *state);
90     virtual void updateRise(GfxState *state);
91     virtual void updateWordSpace(GfxState *state);
92     virtual void updateHorizScaling(GfxState *state);
93     virtual void updateTextPos(GfxState *state);
94     virtual void updateTextShift(GfxState *state, double shift);
95
96     virtual void stroke(GfxState *state);
97     virtual void fill(GfxState *state);
98     virtual void eoFill(GfxState *state);
99     virtual void tilingPatternFill(GfxState *state, Object *str,
100                                    int paintType, Dict *resDict,
101                                    double *mat, double *bbox,
102                                    int x0, int y0, int x1, int y1,
103                                    double xStep, double yStep);
104     virtual GBool functionShadedFill(GfxState *state,
105                                      GfxFunctionShading *shading);
106     virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading);
107     virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading);
108
109     virtual void clip(GfxState *state);
110     virtual void eoClip(GfxState *state);
111     virtual void clipToStrokePath(GfxState *state);
112
113     virtual void beginStringOp(GfxState *state);
114     virtual void endStringOp(GfxState *state);
115     virtual void beginString(GfxState *state, GString *s);
116     virtual void endString(GfxState *state);
117     virtual void drawChar(GfxState *state, double x, double y,
118                           double dx, double dy,
119                           double originX, double originY,
120                           CharCode code, int nBytes, Unicode *u, int uLen);
121     virtual void drawString(GfxState *state, GString *s);
122     virtual GBool beginType3Char(GfxState *state, double x, double y,
123                                  double dx, double dy,
124                                  CharCode code, Unicode *u, int uLen);
125     virtual void endType3Char(GfxState *state);
126     virtual void endTextObject(GfxState *state);
127
128     virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
129                                int width, int height, GBool invert,
130                                GBool inlineImg);
131     virtual void drawImage(GfxState *state, Object *ref, Stream *str,
132                            int width, int height, GfxImageColorMap *colorMap,
133                            int *maskColors, GBool inlineImg);
134     virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
135                                  int width, int height,
136                                  GfxImageColorMap *colorMap,
137                                  Stream *maskStr, int maskWidth, int maskHeight,
138                                  GBool maskInvert);
139     virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
140                                      int width, int height,
141                                      GfxImageColorMap *colorMap,
142                                      Stream *maskStr,
143                                      int maskWidth, int maskHeight,
144                                      GfxImageColorMap *maskColorMap);
145
146     virtual void type3D0(GfxState *state, double wx, double wy);
147     virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
148
149     virtual void drawForm(Ref id);
150
151     virtual void beginTransparencyGroup(GfxState *state, double *bbox,
152                                         GfxColorSpace *blendingColorSpace,
153                                         GBool isolated, GBool knockout,
154                                         GBool forSoftMask);
155     virtual void endTransparencyGroup(GfxState *state);
156     virtual void paintTransparencyGroup(GfxState *state, double *bbox);
157     virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
158     virtual void clearSoftMask(GfxState *state);
159
160 private:
161     void flush();
162
163     char config_bitmapfonts;
164
165     int width, height;
166     PDFDoc*doc;
167     XRef*xref;
168     SplashOutputDev*rgbdev;
169     SplashOutputDev*alphadev;
170     GFXOutputDev*gfxdev;
171     InfoOutputDev*info;
172     gfxdevice_t*dev;
173 };
174
175 #endif