Simplified calculation of minimum crop size in photo editor.

It also fixes cropping of images with unbalanced ratios.
This commit is contained in:
23rd 2021-07-09 12:44:25 +03:00
parent f1669674d8
commit 7526964904
1 changed files with 6 additions and 4 deletions

View File

@ -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(),