diff options
| author | John Bintz <me@johnbintz.com> | 2007-02-27 03:30:27 +0000 |
|---|---|---|
| committer | johncoswell <johncoswell@users.sourceforge.net> | 2007-02-27 03:30:27 +0000 |
| commit | f37faf3573c7f019cd33e4537c1fcf4bbec15f40 (patch) | |
| tree | 4a1a2c19a7fe7976d951ac8a6c9dc024e73cd79b /src/flood-context.cpp | |
| parent | dropping debian directory totally (diff) | |
| download | inkscape-f37faf3573c7f019cd33e4537c1fcf4bbec15f40.tar.gz inkscape-f37faf3573c7f019cd33e4537c1fcf4bbec15f40.zip | |
Flood fill render area now taken from desktop view area and zoom level
(bzr r2453)
Diffstat (limited to 'src/flood-context.cpp')
| -rw-r--r-- | src/flood-context.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 78f8b97dd..abacf6c64 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -363,13 +363,22 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Area is not bounded</b>, cannot fill.")); return; } + + double zoom_scale = desktop->current_zoom(); + double padding = 1.2; + + NR::Rect screen = desktop->get_display_area(); - int width = (int)ceil(bbox.extent(NR::X)); - int height = (int)ceil(bbox.extent(NR::Y)); + int width = (int)ceil(screen.extent(NR::X) * zoom_scale * padding); + int height = (int)ceil(screen.extent(NR::Y) * zoom_scale * padding); - NR::Point origin(bbox.min()[NR::X], bbox.min()[NR::Y]); + NR::Point origin(screen.min()[NR::X], + sp_document_height(document) - screen.extent(NR::Y) - screen.min()[NR::Y]); + + origin[NR::X] = origin[NR::X] + (screen.extent(NR::X) * ((1 - padding) / 2)); + origin[NR::Y] = origin[NR::Y] + (screen.extent(NR::Y) * ((1 - padding) / 2)); - NR::scale scale(width / (bbox.extent(NR::X)), height / (bbox.extent(NR::Y))); + NR::scale scale(zoom_scale, zoom_scale); NR::Matrix affine = scale * NR::translate(-origin * scale); /* Create ArenaItems and set transform */ @@ -404,7 +413,6 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_arena_item_unref(root); nr_object_unref((NRObject *) arena); - double zoom_scale = desktop->current_zoom(); NR::Point pw = NR::Point(event->button.x / zoom_scale, sp_document_height(document) + (event->button.y / zoom_scale)) * affine; @@ -488,6 +496,15 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even } } + GdkPixbuf* pixbuft = gdk_pixbuf_new_from_data(px, + GDK_COLORSPACE_RGB, + TRUE, + 8, width, height, width * 4, + (GdkPixbufDestroyNotify)g_free, + NULL); + + gdk_pixbuf_save(pixbuft, "sample.png", "png", NULL, NULL); + g_free(px); if (aborted) { |
