1 //========================================================================
5 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
16 #include "SplashTypes.h"
19 class SplashGlyphBitmap;
28 //------------------------------------------------------------------------
30 // Retrieves the next pixel in an image mask. Normally, fills in
31 // *<pixel> and returns true. If the image stream is exhausted,
33 typedef GBool (*SplashImageMaskSource)(void *data, SplashMono1 *pixel);
35 // Retrieves the next pixel in an image. Normally, fills in *<pixel>
36 // (pixel color) and *<alpha> (1 for opaque, 0 for transparent), and
37 // returns true. If the image stream is exhausted, returns false.
38 typedef GBool (*SplashImageSource)(void *data, SplashColor *pixel,
41 //------------------------------------------------------------------------
43 //------------------------------------------------------------------------
48 // Create a new rasterizer object.
49 Splash(SplashBitmap *bitmapA);
55 SplashPattern *getStrokePattern();
56 SplashPattern *getFillPattern();
57 SplashScreen *getScreen();
58 SplashCoord getLineWidth();
61 SplashCoord getMiterLimit();
62 SplashCoord getFlatness();
63 SplashCoord *getLineDash();
64 int getLineDashLength();
65 SplashCoord getLineDashPhase();
66 SplashClip *getClip();
70 void setStrokePattern(SplashPattern *strokeColor);
71 void setFillPattern(SplashPattern *fillColor);
72 void setScreen(SplashScreen *screen);
73 void setLineWidth(SplashCoord lineWidth);
74 void setLineCap(int lineCap);
75 void setLineJoin(int lineJoin);
76 void setMiterLimit(SplashCoord miterLimit);
77 void setFlatness(SplashCoord flatness);
78 // the <lineDash> array will be copied
79 void setLineDash(SplashCoord *lineDash, int lineDashLength,
80 SplashCoord lineDashPhase);
81 void clipResetToRect(SplashCoord x0, SplashCoord y0,
82 SplashCoord x1, SplashCoord y1);
83 SplashError clipToRect(SplashCoord x0, SplashCoord y0,
84 SplashCoord x1, SplashCoord y1);
85 SplashError clipToPath(SplashPath *path, GBool eo);
87 //----- state save/restore
90 SplashError restoreState();
92 //----- drawing operations
94 // Fill the bitmap with <color>. This is not subject to clipping.
95 void clear(SplashColor color);
97 // Stroke a path using the current stroke pattern.
98 SplashError stroke(SplashPath *path);
100 // Fill a path using the current fill pattern.
101 SplashError fill(SplashPath *path, GBool eo);
103 // Fill a path, XORing with the current fill pattern.
104 SplashError xorFill(SplashPath *path, GBool eo);
106 // Draw a character, using the current fill pattern.
107 SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
109 // Draw a glyph, using the current fill pattern. This function does
110 // not free any data, i.e., it ignores glyph->freeData.
111 SplashError fillGlyph(SplashCoord x, SplashCoord y,
112 SplashGlyphBitmap *glyph);
114 // Draws an image mask using the fill color. This will read <w>*<h>
115 // pixels from <src>, in raster order, starting with the top line.
116 // "1" pixels will be drawn with the current fill color; "0" pixels
117 // are transparent. The matrix:
118 // [ mat[0] mat[1] 0 ]
119 // [ mat[2] mat[3] 0 ]
120 // [ mat[4] mat[5] 1 ]
121 // maps a unit square to the desired destination for the image, in
123 // [x' y' 1] = [x y 1] * mat
124 // Note that the Splash y axis points downward, and the image source
125 // is assumed to produce pixels in raster order, starting from the
127 SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
128 int w, int h, SplashCoord *mat);
130 // Draw an image. This will read <w>*<h> pixels from <src>, in
131 // raster order, starting with the top line. These pixels are
132 // assumed to be in the source mode, <srcMode>. The following
133 // combinations of source and target modes are supported:
137 // Mono8 Mono1 -- with dithering
140 // BGR8packed BGR8Packed
141 // The matrix behaves as for fillImageMask.
142 SplashError drawImage(SplashImageSource src, void *srcData,
143 SplashColorMode srcMode,
144 int w, int h, SplashCoord *mat);
150 // Return the associated bitmap.
151 SplashBitmap *getBitmap() { return bitmap; }
153 // Toggle debug mode on or off.
154 void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
158 void strokeNarrow(SplashXPath *xPath);
159 void strokeWide(SplashXPath *xPath);
160 SplashXPath *makeDashedPath(SplashXPath *xPath);
161 SplashError fillWithPattern(SplashPath *path, GBool eo,
162 SplashPattern *pattern);
163 void drawPixel(int x, int y, SplashColor *color, GBool noClip);
164 void drawPixel(int x, int y, SplashPattern *pattern, GBool noClip);
165 void drawSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
166 void xorSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
167 void putPixel(int x, int y, SplashColor *pixel);
168 void getPixel(int x, int y, SplashColor *pixel);
169 void dumpPath(SplashPath *path);
171 SplashBitmap *bitmap;