forked from qt-creator/qt-creator
Examples: Fix image scaling for Qt 6
For Qt 6 we must manually convert images to a larger image space before rescaling, otherwise we get dithering effects. Fixes: QTCREATORBUG-26462 Task-number: QTCREATORBUG-24098 Change-Id: I0d7bb70003822d61d6bc4bc571d29ef82c4dbb0e Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
@@ -82,17 +82,20 @@ QImage ScreenshotCropper::croppedImage(const QImage &sourceImage, const QString
|
||||
{
|
||||
const QRect areaOfInterest = welcomeScreenAreas()->areas.value(fileNameForPath(filePath));
|
||||
|
||||
QImage result;
|
||||
if (areaOfInterest.isValid()) {
|
||||
const QRect cropRect = cropRectForAreaOfInterest(sourceImage.size(), cropSize, areaOfInterest);
|
||||
const QSize cropRectSize = cropRect.size();
|
||||
const QImage result = sourceImage.copy(cropRect);
|
||||
if (cropRectSize.width() > cropSize.width() || cropRectSize.height() > cropSize.height())
|
||||
return result.scaled(cropSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
else
|
||||
result = sourceImage.copy(cropRect);
|
||||
if (cropRectSize.width() <= cropSize.width() && cropRectSize.height() <= cropSize.height())
|
||||
return result;
|
||||
} else {
|
||||
result = sourceImage;
|
||||
}
|
||||
|
||||
return sourceImage.scaled(cropSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if (result.format() != QImage::Format_ARGB32)
|
||||
result = result.convertToFormat(QImage::Format_ARGB32);
|
||||
return result.scaled(cropSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
static int areaAttribute(const QXmlStreamAttributes &attributes, const QString &name)
|
||||
|
||||
Reference in New Issue
Block a user