diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2009-01-13 02:27:04 +0000 |
|---|---|---|
| committer | tweenk <tweenk@users.sourceforge.net> | 2009-01-13 02:27:04 +0000 |
| commit | a3648f82f9e66ecc2dd355e9d0c5b2f3e66b9b50 (patch) | |
| tree | 9efdab733f1ae2b3580143a0e1c91a934a020712 /src/trace | |
| parent | Latest set of tango icons (by jEsuSdA 8) ) (diff) | |
| download | inkscape-a3648f82f9e66ecc2dd355e9d0c5b2f3e66b9b50.tar.gz inkscape-a3648f82f9e66ecc2dd355e9d0c5b2f3e66b9b50.zip | |
Improved version reporting. Add SVN revision and custom status to
version string on Linux.
(bzr r7123)
Diffstat (limited to 'src/trace')
| -rw-r--r-- | src/trace/potrace/potracelib.cpp | 131 |
1 files changed, 72 insertions, 59 deletions
diff --git a/src/trace/potrace/potracelib.cpp b/src/trace/potrace/potracelib.cpp index 36b3a5f94..c9e9a7125 100644 --- a/src/trace/potrace/potracelib.cpp +++ b/src/trace/potrace/potracelib.cpp @@ -4,9 +4,10 @@ #include <stdlib.h> #include <string.h> +#include <glib/gprintf.h> #include "potracelib.h" -#include <inkscape_version.h> +#include "inkscape-version.h" #include "curve.h" #include "decompose.h" #include "trace.h" @@ -34,14 +35,14 @@ static const potrace_param_t param_default = { /* Return a fresh copy of the set of default parameters, or NULL on failure with errno set. */ potrace_param_t *potrace_param_default(void) { - potrace_param_t *p; - - p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); - if (!p) { - return NULL; - } - memcpy(p, ¶m_default, sizeof(potrace_param_t)); - return p; + potrace_param_t *p; + + p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); + if (!p) { + return NULL; + } + memcpy(p, ¶m_default, sizeof(potrace_param_t)); + return p; } /* On success, returns a Potrace state st with st->status == @@ -50,65 +51,77 @@ potrace_param_t *potrace_param_default(void) { state (with st->status == POTRACE_STATUS_INCOMPLETE). Complete or incomplete Potrace state can be freed with potrace_state_free(). */ potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm) { - int r; - path_t *plist = NULL; - potrace_state_t *st; - progress_t prog; - progress_t subprog; - - /* prepare private progress bar state */ - prog.callback = param->progress.callback; - prog.data = param->progress.data; - prog.min = param->progress.min; - prog.max = param->progress.max; - prog.epsilon = param->progress.epsilon; - prog.d_prev = param->progress.min; - - /* allocate state object */ - st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); - if (!st) { - return NULL; - } - - progress_subrange_start(0.0, 0.1, &prog, &subprog); - - /* process the image */ - r = bm_to_pathlist(bm, &plist, param, &subprog); - if (r) { - free(st); - return NULL; - } - - st->status = POTRACE_STATUS_OK; - st->plist = plist; - st->priv = NULL; /* private state currently unused */ - - progress_subrange_end(&prog, &subprog); - - progress_subrange_start(0.1, 1.0, &prog, &subprog); - - /* partial success. */ - r = process_path(plist, param, &subprog); - if (r) { - st->status = POTRACE_STATUS_INCOMPLETE; - } - - progress_subrange_end(&prog, &subprog); - - return st; + int r; + path_t *plist = NULL; + potrace_state_t *st; + progress_t prog; + progress_t subprog; + + /* prepare private progress bar state */ + prog.callback = param->progress.callback; + prog.data = param->progress.data; + prog.min = param->progress.min; + prog.max = param->progress.max; + prog.epsilon = param->progress.epsilon; + prog.d_prev = param->progress.min; + + /* allocate state object */ + st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); + if (!st) { + return NULL; + } + + progress_subrange_start(0.0, 0.1, &prog, &subprog); + + /* process the image */ + r = bm_to_pathlist(bm, &plist, param, &subprog); + if (r) { + free(st); + return NULL; + } + + st->status = POTRACE_STATUS_OK; + st->plist = plist; + st->priv = NULL; /* private state currently unused */ + + progress_subrange_end(&prog, &subprog); + + progress_subrange_start(0.1, 1.0, &prog, &subprog); + + /* partial success. */ + r = process_path(plist, param, &subprog); + if (r) { + st->status = POTRACE_STATUS_INCOMPLETE; + } + + progress_subrange_end(&prog, &subprog); + + return st; } /* free a Potrace state, without disturbing errno. */ void potrace_state_free(potrace_state_t *st) { - pathlist_free(st->plist); - free(st); + pathlist_free(st->plist); + free(st); } /* free a parameter list, without disturbing errno. */ void potrace_param_free(potrace_param_t *p) { - free(p); + free(p); } char *potrace_version(void) { - return "potracelib "INKSCAPE_VERSION""; + static char *ver = g_strdup_printf("potracelib %s", Inkscape::version_string); + return ver; } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
