summaryrefslogtreecommitdiffstats
path: root/src/trace/potrace/inkscape-potrace.h
blob: c4c7bf4c633c892c9ff86ed5e5b0776991fd46fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * This is the C++ glue between Inkscape and Potrace
 *
 * Authors:
 *   Bob Jamison <rjamison@titan.com>
 *   Stéphane Gimenez <dev@gim.name>
 *
 * Copyright (C) 2004-2006 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 *
 * Potrace, the wonderful tracer located at http://potrace.sourceforge.net,
 * is provided by the generosity of Peter Selinger, to whom we are grateful.
 *
 */

#ifndef __INKSCAPE_POTRACE_H__
#define __INKSCAPE_POTRACE_H__

#include <trace/trace.h>
#include <potracelib.h>

struct GrayMap_def;
typedef GrayMap_def GrayMap;

namespace Inkscape {

namespace Trace {

namespace Potrace {

enum TraceType
    {
    TRACE_BRIGHTNESS,
    TRACE_BRIGHTNESS_MULTI,
    TRACE_CANNY,
    TRACE_QUANT,
    TRACE_QUANT_COLOR,
    TRACE_QUANT_MONO,
    // Used in tradedialog.cpp
    AUTOTRACE_SINGLE,
    AUTOTRACE_MULTI,
    AUTOTRACE_CENTERLINE
    };


class PotraceTracingEngine : public TracingEngine
{

    public:

    /**
     *
     */
    PotraceTracingEngine();
    PotraceTracingEngine(TraceType traceType, bool invert, int quantizationNrColors, double brightnessThreshold, double brightnessFloor, double cannyHighThreshold, int multiScanNrColors, bool multiScanStack, bool multiScanSmooth, bool multiScanRemoveBackground);

    /**
     *
     */
    ~PotraceTracingEngine() override;

    /**
     *  This is the working method of this implementing class, and all
     *  implementing classes.  Take a GdkPixbuf, trace it, and
     *  return the path data that is compatible with the d="" attribute
     *  of an SVG <path> element.
     */
    std::vector<TracingEngineResult> trace(
                        Glib::RefPtr<Gdk::Pixbuf> pixbuf) override;

    /**
     *  Abort the thread that is executing getPathDataFromPixbuf()
     */
    void abort() override;

    /**
     *
     */
    Glib::RefPtr<Gdk::Pixbuf> preview(Glib::RefPtr<Gdk::Pixbuf> pixbuf);

    /**
     *
     */
    int keepGoing;

    std::vector<TracingEngineResult>traceGrayMap(GrayMap *grayMap);

    potrace_param_t *potraceParams;
    TraceType traceType;

    //## do I invert at the end?
    bool invert;

    //## Color-->b&w quantization
    int quantizationNrColors;

    //## brightness items
    double brightnessThreshold;
    double brightnessFloor; //usually 0.0

    //## canny items
    double cannyHighThreshold;

    //## Color-->multiscan quantization
    int multiScanNrColors;
    bool multiScanStack; //do we tile or stack?
    bool multiScanSmooth;//do we use gaussian filter?
    bool multiScanRemoveBackground; //do we remove the bottom trace?
    
    private:
    /**
     * This is the actual wrapper of the call to Potrace.  nodeCount
     * returns the count of nodes created.  May be NULL if ignored.
     */
    std::string grayMapToPath(GrayMap *gm, long *nodeCount);

    std::vector<TracingEngineResult>traceBrightnessMulti(GdkPixbuf *pixbuf);
    std::vector<TracingEngineResult>traceQuant(GdkPixbuf *pixbuf);
    std::vector<TracingEngineResult>traceSingle(GdkPixbuf *pixbuf);


};//class PotraceTracingEngine



}  // namespace Potrace
}  // namespace Trace
}  // namespace Inkscape


#endif  //__INKSCAPE_POTRACE_H__


/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :