Code

patch [ 1503865 ] Siox performance patch
[inkscape.git] / src / trace / potrace / inkscape-potrace.h
1 /*
2  * This is the C++ glue between Inkscape and Potrace
3  *
4  * Authors:
5  *   Bob Jamison <rjamison@titan.com>
6  *
7  * Copyright (C) 2004 Bob Jamison
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  *
11  * Potrace, the wonderful tracer located at http://potrace.sourceforge.net,
12  * is provided by the generosity of Peter Selinger, to whom we are grateful.
13  *
14  */
16 #ifndef __INKSCAPE_POTRACE_H__
17 #define __INKSCAPE_POTRACE_H__
19 #include <gtkmm.h>
20 #include <trace/trace.h>
21 #include <trace/imagemap.h>
23 namespace Inkscape {
25 namespace Trace {
27 namespace Potrace {
29 typedef enum
30     {
31     TRACE_BRIGHTNESS,
32     TRACE_BRIGHTNESS_MULTI,
33     TRACE_CANNY,
34     TRACE_QUANT,
35     TRACE_QUANT_COLOR,
36     TRACE_QUANT_MONO
37     } TraceType;
40 class PotraceTracingEngine : public TracingEngine
41 {
43     public:
45     /**
46      *
47      */
48     PotraceTracingEngine();
50     /**
51      *
52      */
53     virtual ~PotraceTracingEngine()
54         {}
56     void setTraceType(TraceType val)
57         {
58         traceType = val;
59         }
60     TraceType getTraceType()
61         {
62         return traceType;
63         }
65     /**
66      * Sets/gets whether I invert the product of the other filter(s)
67      */
68     void setInvert(bool val)
69         {
70         invert = val;
71         }
72     bool getInvert()
73         {
74         return invert;
75         }
77     /**
78      * Sets the halfway point for black/white
79      */
80     void setQuantizationNrColors(int val)
81         {
82         quantizationNrColors = val;
83         }
84     int getQuantizationNrColors()
85         {
86         return quantizationNrColors;
87         }
89     /**
90      * Sets the halfway point for black/white
91      */
92     void setBrightnessThreshold(double val)
93         {
94         brightnessThreshold = val;
95         }
96     double getBrightnessThreshold()
97         {
98         return brightnessThreshold;
99         }
101     /**
102      * Sets the lower consideration point for black/white
103      */
104     void setBrightnessFloor(double val)
105         {
106         brightnessFloor = val;
107         }
108     double getBrightnessFloor()
109         {
110         return brightnessFloor;
111         }
113     /**
114      * Sets upper cutoff for canny non-maximalizing
115      */
116     void setCannyHighThreshold(double val)
117         {
118         cannyHighThreshold = val;
119         }
120     double getCannyHighThreshold()
121         {
122         return cannyHighThreshold;
123         }
125     /**
126      * Sets the number of colors for quant multiscan
127      */
128     void setMultiScanNrColors(int val)
129         {
130         multiScanNrColors = val;
131         }
132     int getMultiScanNrColors()
133         {
134         return multiScanNrColors;
135         }
137     /**
138      * Sets whether we tile regions side-by-side or stack them
139      */
140     void setMultiScanStack(bool val)
141         {
142         multiScanStack = val;
143         }
144     bool setMultiScanStack()
145         {
146         return multiScanStack;
147         }
149     /**
150      * Sets whether we want gaussian smoothing of bitmaps before quantizing
151      */
152     void setMultiScanSmooth(bool val)
153         {
154         multiScanSmooth = val;
155         }
156     bool getMultiScanSmooth()
157         {
158         return multiScanSmooth;
159         }
162     /**
163      *  This is the working method of this implementing class, and all
164      *  implementing classes.  Take a GdkPixbuf, trace it, and
165      *  return the path data that is compatible with the d="" attribute
166      *  of an SVG <path> element.
167      */
168     virtual TracingEngineResult *trace(Glib::RefPtr<Gdk::Pixbuf> pixbuf,
169                                        int *nrPaths);
171     /**
172      *  Abort the thread that is executing getPathDataFromPixbuf()
173      */
174     virtual void abort();
176     /**
177      *
178      */
179     Glib::RefPtr<Gdk::Pixbuf> preview(Glib::RefPtr<Gdk::Pixbuf> pixbuf);
181     /**
182      *
183      */
184     int keepGoing;
188     private:
190     TraceType traceType;
192     //## do i invert at the end?
193     bool invert;
195     //## Color-->b&w quantization
196     int quantizationNrColors;
198     //## brightness items
199     double brightnessThreshold;
200     double brightnessFloor; //usually 0.0
202     //## canny items
203     double cannyHighThreshold;
205     //## Color-->multiscan quantization
206     int multiScanNrColors;
207     bool multiScanStack; //do we tile or stack?
208     bool multiScanSmooth;//do we use gaussian filter?
210     /**
211      * This is the actual wrapper of the call to Potrace.  nodeCount
212      * returns the count of nodes created.  May be NULL if ignored.
213      */
214     char *grayMapToPath(GrayMap *gm, long *nodeCount);
216     TracingEngineResult *traceBrightnessMulti(GdkPixbuf *pixbuf, int *nrPaths);
217     TracingEngineResult *traceQuant(GdkPixbuf *pixbuf, int *nrPaths);
218     TracingEngineResult *traceSingle(GdkPixbuf *pixbuf, int *nrPaths);
221 };//class PotraceTracingEngine
225 }  // namespace Potrace
226 }  // namespace Trace
227 }  // namespace Inkscape
230 #endif  //__INKSCAPE_POTRACE_H__