From 75269649048fdc1150e3d31aad0793c4551e3586 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 9 Jul 2021 12:44:25 +0300 Subject: [PATCH] Simplified calculation of minimum crop size in photo editor. It also fixes cropping of images with unbalanced ratios. --- Telegram/SourceFiles/editor/editor_crop.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/editor/editor_crop.cpp b/Telegram/SourceFiles/editor/editor_crop.cpp index 7ef26b1f3..06d3c4700 100644 --- a/Telegram/SourceFiles/editor/editor_crop.cpp +++ b/Telegram/SourceFiles/editor/editor_crop.cpp @@ -269,10 +269,12 @@ void Crop::performCrop(const QPoint &pos) { } const auto &minSize = st::photoEditorCropMinSize; - const auto xMin = int(xFactor * crop.width() - - xFactor * minSize * ((cropRatio > 1.) ? cropRatio : 1.)); - const auto yMin = int(yFactor * crop.height() - - yFactor * minSize * ((cropRatio < 1.) ? (1. / cropRatio) : 1.)); + const auto xMin = xFactor * int(crop.width() - minSize); + // const auto xMin = int(xFactor * crop.width() + // - xFactor * minSize * ((cropRatio > 1.) ? cropRatio : 1.)); + const auto yMin = yFactor * int(crop.height() - minSize); + // const auto yMin = int(yFactor * crop.height() + // - yFactor * minSize * ((cropRatio < 1.) ? (1. / cropRatio) : 1.)); const auto x = std::clamp( diff.x(),