1 //========================================================================
2 //
3 // ImageOutputDev.h
4 //
5 // Copyright 1998-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef IMAGEOUTPUTDEV_H
10 #define IMAGEOUTPUTDEV_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include <stdio.h>
19 #include "gtypes.h"
20 #include "OutputDev.h"
21 
22 class GfxImageColorMap;
23 class GfxState;
24 
25 //------------------------------------------------------------------------
26 // ImageOutputDev
27 //------------------------------------------------------------------------
28 
29 class ImageOutputDev: public OutputDev {
30 public:
31 
32   // Create an OutputDev which will write images to files named
33   // <fileRoot>-NNN.<type>.  Normally, all images are written as PBM
34   // (.pbm) or PPM (.ppm) files.  If <dumpJPEG> is set, JPEG images
35   // are written as JPEG (.jpg) files.  If <dumpRaw> is set, all
36   // images are written in PDF-native formats.  If <list> is set, a
37   // one-line summary will be written to stdout for each image.
38   ImageOutputDev(char *fileRootA, GBool dumpJPEGA, GBool dumpRawA,
39 		 GBool listA);
40 
41   // Destructor.
42   virtual ~ImageOutputDev();
43 
44   // Check if file was successfully created.
isOk()45   virtual GBool isOk() { return ok; }
46 
47   // Does this device use tilingPatternFill()?  If this returns false,
48   // tiling pattern fills will be reduced to a series of other drawing
49   // operations.
useTilingPatternFill()50   virtual GBool useTilingPatternFill() { return gTrue; }
51 
52   // Does this device use beginType3Char/endType3Char?  Otherwise,
53   // text in Type 3 fonts will be drawn with drawChar/drawString.
interpretType3Chars()54   virtual GBool interpretType3Chars() { return gFalse; }
55 
56   // Does this device need non-text content?
needNonText()57   virtual GBool needNonText() { return gTrue; }
58 
59   //---- get info about output device
60 
61   // Does this device use upside-down coordinates?
62   // (Upside-down means (0,0) is the top left corner of the page.)
upsideDown()63   virtual GBool upsideDown() { return gTrue; }
64 
65   // Does this device use drawChar() or drawString()?
useDrawChar()66   virtual GBool useDrawChar() { return gFalse; }
67 
68   //----- initialization and control
69   virtual void startPage(int pageNum, GfxState *state);
70 
71   //----- path painting
72   virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *strRef,
73 				 int paintType, int tilingType, Dict *resDict,
74 				 double *mat, double *bbox,
75 				 int x0, int y0, int x1, int y1,
76 				 double xStep, double yStep);
77 
78   //----- image drawing
79   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
80 			     int width, int height, GBool invert,
81 			     GBool inlineImg, GBool interpolate);
82   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
83 			 int width, int height, GfxImageColorMap *colorMap,
84 			 int *maskColors, GBool inlineImg, GBool interpolate);
85   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
86 			       int width, int height,
87 			       GfxImageColorMap *colorMap,
88 			       Object *maskRef, Stream *maskStr,
89 			       int maskWidth, int maskHeight,
90 			       GBool maskInvert, GBool interpolate);
91   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
92 				   int width, int height,
93 				   GfxImageColorMap *colorMap,
94 				   Object *maskRef, Stream *maskStr,
95 				   int maskWidth, int maskHeight,
96 				   GfxImageColorMap *maskColorMap,
97 				   double *matte, GBool interpolate);
98 
99 private:
100 
101   Stream *getRawStream(Stream *str);
102   const char *getRawFileExtension(Stream *str);
103   void writeImageInfo(GString *fileName,
104 		      int width, int height, GfxState *state,
105 		      GfxImageColorMap *colorMap);
106 
107   char *fileRoot;		// root of output file names
108   GBool dumpJPEG;		// set to dump native JPEG files
109   GBool dumpRaw;		// set to dump raw PDF-native image files
110   GBool list;			// set to write image info to stdout
111   int imgNum;			// current image number
112   int curPageNum;		// current page number
113   GBool ok;			// set up ok?
114 };
115 
116 #endif
117