From 3afc53d866282a4fa8adda31c2adb3734eceb53b Mon Sep 17 00:00:00 2001 From: Mark Schmitz Date: Wed, 18 Dec 2013 18:35:06 +0100 Subject: [PATCH] Bug 720711 - gimpressionist: Background paper is not aligned... ...with the painted image gimpressionist: fix alignment of image and background paper. Additionally the resize function is now skipped for a scale of 100%. --- plug-ins/gimpressionist/repaint.c | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plug-ins/gimpressionist/repaint.c b/plug-ins/gimpressionist/repaint.c index ca7cbe2254..5b0bf70e4a 100644 --- a/plug-ins/gimpressionist/repaint.c +++ b/plug-ins/gimpressionist/repaint.c @@ -553,22 +553,37 @@ repaint (ppm_t *p, ppm_t *a) } else { - scale = runningvals.paper_scale / 100.0; + int dx, dy; + ppm_new (&tmp, p->width, p->height); ppm_load (runningvals.selected_paper, &paper_ppm); - resize (&paper_ppm, paper_ppm.width * scale, paper_ppm.height * scale); + + if (runningvals.paper_scale != 100.0) + { + scale = runningvals.paper_scale / 100.0; + resize (&paper_ppm, paper_ppm.width * scale, paper_ppm.height * scale); + } + if (runningvals.paper_invert) ppm_apply_gamma (&paper_ppm, -1.0, 1, 1, 1); - for (x = 0; x < tmp.width; x++) - { - int rx = x % paper_ppm.width; - for (y = 0; y < tmp.height; y++) + dx = runningvals.general_paint_edges ? paper_ppm.width - maxbrushwidth : 0; + dy = runningvals.general_paint_edges ? paper_ppm.height - maxbrushheight : 0; + + for (y = 0; y < tmp.height; y++) + { + int lx; + int ry = (y + dy) % paper_ppm.height; + + for (x = 0; x < tmp.width; x+=lx) { - int ry = y % paper_ppm.height; + int rx = (x + dx) % paper_ppm.width; + + lx = MIN (tmp.width - x, paper_ppm.width - rx); + memcpy (&tmp.col[y * tmp.width * 3 + x * 3], - &paper_ppm.col[ry*paper_ppm.width*3+rx*3], - 3); + &paper_ppm.col[ry * paper_ppm.width * 3 + rx * 3], + 3 * lx); } } }