diff options
| author | John Bintz <me@johnbintz.com> | 2008-04-17 22:43:15 +0000 |
|---|---|---|
| committer | johncoswell <johncoswell@users.sourceforge.net> | 2008-04-17 22:43:15 +0000 |
| commit | 2649307b3d505e3b49b8e9199a5cea90f0205b81 (patch) | |
| tree | 1ccaca08199b9a810537cce776118836a04d070a /src/flood-context.cpp | |
| parent | Following the previous commit - update to the INX files - a step towards prop... (diff) | |
| download | inkscape-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/flood-context.cpp')
| -rw-r--r-- | src/flood-context.cpp | 34 |
1 files changed, 17 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); |
