summaryrefslogtreecommitdiffstats
path: root/src/dialogs/clonetiler.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-08-14 19:22:11 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-08-14 19:22:11 +0000
commitaa844be794b36b44b624e579db7f0945b5d3927b (patch)
treef83306b1ac51d8089373023162945eb25951bf68 /src/dialogs/clonetiler.cpp
parentFix paint bucket tool (diff)
downloadinkscape-aa844be794b36b44b624e579db7f0945b5d3927b.tar.gz
inkscape-aa844be794b36b44b624e579db7f0945b5d3927b.zip
Completely remove NRPixBlock
(bzr r9508.1.67)
Diffstat (limited to 'src/dialogs/clonetiler.cpp')
-rw-r--r--src/dialogs/clonetiler.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp
index 2be5b2ddc..3fe6b59e3 100644
--- a/src/dialogs/clonetiler.cpp
+++ b/src/dialogs/clonetiler.cpp
@@ -901,45 +901,17 @@ clonetiler_trace_pick (Geom::Rect box)
/* Find visible area */
int width = ibox.x1 - ibox.x0;
int height = ibox.y1 - ibox.y0;
+ double R = 0, G = 0, B = 0, A = 0;
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *ct = cairo_create(s);
-
/* Render */
nr_arena_item_invoke_render(ct, trace_root, &ibox, NULL,
NR_ARENA_ITEM_RENDER_NO_CACHE );
- cairo_surface_flush(s);
cairo_destroy(ct);
-
- double R = 0, G = 0, B = 0, A = 0;
- double count = 0;
-
- /* TODO convert this to OpenMP somehow */
- unsigned char *data = cairo_image_surface_get_data(s);
- int stride = cairo_image_surface_get_stride(s);
- for (int y=0; y < height; ++y, data += stride) {
- for (int x=0; x < width; ++x) {
- guint32 px = *reinterpret_cast<guint32*>(data + 4*x);
- EXTRACT_ARGB32(px, a,r,g,b)
- count += 1.0;
- R += r / 255.0;
- G += g / 255.0;
- B += b / 255.0;
- A += a / 255.0;
- }
- }
+ ink_cairo_surface_average_color(s, R, G, B, A);
cairo_surface_destroy(s);
- R = R / A;
- G = G / A;
- B = B / A;
- A = A / count;
-
- R = CLAMP (R, 0.0, 1.0);
- G = CLAMP (G, 0.0, 1.0);
- B = CLAMP (B, 0.0, 1.0);
- A = CLAMP (A, 0.0, 1.0);
-
return SP_RGBA32_F_COMPOSE (R, G, B, A);
}