From c4a201eaf4e7cf6ec8a76768e6bb27dcbe2e94f8 Mon Sep 17 00:00:00 2001 From: Ell Date: Fri, 12 Jun 2020 17:20:23 +0300 Subject: [PATCH] Issue #5208 - paint brush is broken when aspect ratio is set to negative Fix horizontal downscaling of brush mipmap levels with odd width. We'd previously fail to skip the last pixel of each input row, which isn't included in the output when the width is odd, causing subsequent output rows to be shifted to the right. --- app/core/gimpbrush-mipmap.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/core/gimpbrush-mipmap.cc b/app/core/gimpbrush-mipmap.cc index ae394dc3e9..7c3b061130 100644 --- a/app/core/gimpbrush-mipmap.cc +++ b/app/core/gimpbrush-mipmap.cc @@ -292,16 +292,20 @@ struct MipmapAlgorithms [=] (gint offset, gint size) { - const T *src = (const T *) gimp_temp_buf_get_data (source); - T *dest = (T *) gimp_temp_buf_get_data (destination); + const T *src0 = (const T *) gimp_temp_buf_get_data (source); + T *dest0 = (T *) gimp_temp_buf_get_data (destination); + gint src_stride = N * gimp_temp_buf_get_width (source); + gint dest_stride = N * gimp_temp_buf_get_width (destination); gint y; - src += offset * gimp_temp_buf_get_width (source) * N; - dest += offset * gimp_temp_buf_get_width (destination) * N; + src0 += offset * src_stride; + dest0 += offset * dest_stride; for (y = 0; y < size; y++) { - gint x; + const T *src = src0; + T *dest = dest0; + gint x; for (x = 0; x < width; x++) { @@ -313,6 +317,9 @@ struct MipmapAlgorithms src += 2 * N; dest += N; } + + src0 += src_stride; + dest0 += dest_stride; } });