summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Bintz <me@johnbintz.com>2008-04-17 22:43:15 +0000
committerjohncoswell <johncoswell@users.sourceforge.net>2008-04-17 22:43:15 +0000
commit2649307b3d505e3b49b8e9199a5cea90f0205b81 (patch)
tree1ccaca08199b9a810537cce776118836a04d070a /src
parentFollowing the previous commit - update to the INX files - a step towards prop... (diff)
downloadinkscape-2649307b3d505e3b49b8e9199a5cea90f0205b81.tar.gz
inkscape-2649307b3d505e3b49b8e9199a5cea90f0205b81.zip
Have Paint Bucket generate the necessary GrayMap for potrace directly, skipping the standard, slower potrace filtering routines.
(bzr r5466)
Diffstat (limited to 'src')
-rw-r--r--src/flood-context.cpp34
-rw-r--r--src/trace/potrace/inkscape-potrace.cpp24
-rw-r--r--src/trace/potrace/inkscape-potrace.h1
3 files changed, 42 insertions, 17 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index c6335cb0f..f58ab0830 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -67,6 +67,7 @@
#include "color.h"
#include "trace/trace.h"
+#include "trace/imagemap.h"
#include "trace/potrace/inkscape-potrace.h"
static void sp_flood_context_class_init(SPFloodContextClass *klass);
@@ -402,18 +403,24 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_
* \param transform The transform to apply to the final SVG path.
* \param union_with_selection If true, merge the final SVG path with the current selection.
*/
-static void do_trace(GdkPixbuf *px, SPDesktop *desktop, NR::Matrix transform, bool union_with_selection) {
+static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, NR::Matrix transform, bool union_with_selection) {
SPDocument *document = sp_desktop_document(desktop);
-
+
+ unsigned char *trace_t;
+
+ GrayMap *gray_map = GrayMapCreate(bci.width, bci.height);
+ for (unsigned int y = 0; y < bci.height ; y++) {
+ trace_t = get_pixel(trace_px, 0, y, bci.width);
+ for (unsigned int x = 0; x < bci.width ; x++) {
+ gray_map->setPixel(gray_map, x, y, is_pixel_colored(trace_t) ? GRAYMAP_BLACK : GRAYMAP_WHITE);
+ trace_t += 4;
+ }
+ }
+
Inkscape::Trace::Potrace::PotraceTracingEngine pte;
-
- pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS);
- pte.setInvert(false);
+ std::vector<Inkscape::Trace::TracingEngineResult> results = pte.traceGrayMap(gray_map);
+ gray_map->destroy(gray_map);
- Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(px, true);
-
- std::vector<Inkscape::Trace::TracingEngineResult> results = pte.trace(pixbuf);
-
Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->repr;
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
@@ -1091,16 +1098,9 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Only the visible part of the bounded area was filled.</b> If you want to fill all of the area, undo, zoom out, and fill again."));
}
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(trace_px,
- GDK_COLORSPACE_RGB,
- TRUE,
- 8, width, height, width * 4,
- (GdkPixbufDestroyNotify)g_free,
- NULL);
-
NR::Matrix inverted_affine = NR::Matrix(affine).inverse();
- do_trace(pixbuf, desktop, inverted_affine, union_with_selection);
+ do_trace(bci, trace_px, desktop, inverted_affine, union_with_selection);
g_free(trace_px);
diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp
index bad4278e2..9a305cc7c 100644
--- a/src/trace/potrace/inkscape-potrace.cpp
+++ b/src/trace/potrace/inkscape-potrace.cpp
@@ -445,6 +445,30 @@ PotraceTracingEngine::traceSingle(GdkPixbuf * thePixbuf)
/**
+ * This allow routines that already generate GrayMaps to skip image filtering,
+ * increasing performance.
+ */
+std::vector<TracingEngineResult>
+PotraceTracingEngine::traceGrayMap(GrayMap *grayMap)
+{
+
+ std::vector<TracingEngineResult> results;
+
+ brightnessFloor = 0.0; //important to set this
+
+ long nodeCount;
+ std::string d = grayMapToPath(grayMap, &nodeCount);
+
+ char *style = "fill:#000000";
+
+ //g_message("### GOT '%s' \n", d);
+ TracingEngineResult result(style, d, nodeCount);
+ results.push_back(result);
+
+ return results;
+}
+
+/**
* Called for multiple-scanning algorithms
*/
std::vector<TracingEngineResult>
diff --git a/src/trace/potrace/inkscape-potrace.h b/src/trace/potrace/inkscape-potrace.h
index 838a1363a..b32ab6461 100644
--- a/src/trace/potrace/inkscape-potrace.h
+++ b/src/trace/potrace/inkscape-potrace.h
@@ -237,6 +237,7 @@ class PotraceTracingEngine : public TracingEngine
*/
int keepGoing;
+ std::vector<TracingEngineResult>traceGrayMap(GrayMap *grayMap);
private: