From 9165d0acb7ba312d6eb57010cbf48f3eb0688602 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Thu, 5 Sep 2019 12:08:36 +0200 Subject: [PATCH] Crop area not shown on File Browser window thumbnails, fixes #5440 --- rtengine/rtthumbnail.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 1ffaf939a..2c78e84bf 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1483,29 +1483,33 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT delete labView; delete baseImg; - /* - // calculate scale - if (params.coarse.rotate == 90 || params.coarse.rotate == 270) { - myscale = scale * thumbImg->getWidth() / fh; - } else { - myscale = scale * thumbImg->getHeight() / fh; - } - myscale = 1.0 / myscale; + // apply crop if (params.crop.enabled) { + double lscale; + // calculate scale + if (params.coarse.rotate == 90 || params.coarse.rotate == 270) { + lscale = scale * thumbImg->getWidth() / fh; + } else { + lscale = scale * thumbImg->getHeight() / fh; + } + + lscale = 1.0 / lscale; int ix = 0; - for (int i=0; i(params.crop.y+params.crop.h)/myscale || j(params.crop.x+params.crop.w)/myscale) { + for (int i = 0; i < fh; ++i) { + for (int j = 0; j < fw; ++j) { + if (i < params.crop.y * lscale || i > (params.crop.y + params.crop.h) * lscale || j < params.crop.x * lscale || j > (params.crop.x + params.crop.w) * lscale) { readyImg->data[ix++] /= 3; readyImg->data[ix++] /= 3; readyImg->data[ix++] /= 3; - } - else + } else { ix += 3; + } + } + } } - */ + return readyImg; }