From f03c1980a08df4ff0f6ed1ba1d435de1251cee35 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Tue, 10 Mar 2026 11:38:31 +0800 Subject: [PATCH] chore: update copyright year and improve image scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the copyright year range from 2022 to 2022-2026 in the file header. Modified the image scaling logic in ErollThread::processCapturedImage to use center-cropping instead of simple scaling when the preview image size is not 800x600. This ensures the captured image maintains its aspect ratio and focuses on the central region, preventing distortion that could occur with non-uniform scaling. The new method calculates the appropriate source rectangle based on the larger required scale factor, crops from the center, and then scales to the target dimensions. chore: 更新版权年份并改进图像缩放 更新了文件头中的版权年份范围,从2022年改为2022-2026年。 修改了ErollThread::processCapturedImage中的图像缩放逻辑,当预览图像尺寸 不是800x600时,使用中心裁剪代替简单的缩放。这确保了捕获的图像保持其宽高 比并聚焦于中央区域,防止了非均匀缩放可能导致的失真。新方法根据所需的最大 缩放因子计算适当的源矩形,从中心裁剪,然后缩放到目标尺寸。 PMS: BUG-304729 --- workmodule.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/workmodule.cpp b/workmodule.cpp index f2005ea..c538578 100644 --- a/workmodule.cpp +++ b/workmodule.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -144,10 +144,19 @@ void ErollThread::processCapturedImage(int id, const QImage &preview) return; QImage img; - if (preview.size() == QSize(800, 600)) + if (preview.size() == QSize(800, 600)) { img = preview; - else - img = preview.scaled(QSize(800, 600)); + } else { + const int pw = preview.width(); + const int ph = preview.height(); + double scale = qMax(800.0 / pw, 600.0 / ph); + int srcW = qRound(800.0 / scale); + int srcH = qRound(600.0 / scale); + int srcX = (pw - srcW) / 2; + int srcY = (ph - srcH) / 2; + img = preview.copy(srcX, srcY, srcW, srcH) + .scaled(800, 600, Qt::IgnoreAspectRatio, Qt::FastTransformation); + } if (1 == id) { sendCapture(img);