mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-25 10:40:38 +01:00
Qt5: respect canvas setting for antialiasing when enabling smooth transformations. issue #33011
git-svn-id: trunk@57132 -
This commit is contained in:
parent
784b31cbda
commit
1d8aa3615d
@ -3434,6 +3434,8 @@ var
|
||||
ScaledMask: QImageH;
|
||||
NewRect: TRect;
|
||||
ARenderHint: Boolean;
|
||||
ATransformation: QtTransformationMode;
|
||||
ARenderHints: QPainterRenderHints;
|
||||
|
||||
function NeedScaling: boolean;
|
||||
var
|
||||
@ -3568,9 +3570,17 @@ begin
|
||||
ScaledImage := QImage_create();
|
||||
try
|
||||
QImage_copy(Image, ScaledImage, 0, 0, QImage_width(Image), QImage_height(Image));
|
||||
// use smooth transformation when scaling image. issue #29883
|
||||
{use smooth transformation when scaling image. issue #29883
|
||||
check if antialiasing is on, if not then don''t call smoothTransform. issue #330011}
|
||||
ARenderHints := QPainter_renderHints(Widget);
|
||||
if (ARenderHints and QPainterAntialiasing <> 0) or (ARenderHints and QPainterSmoothPixmapTransform <> 0) or
|
||||
(ARenderHints and QPainterHighQualityAntialiasing <> 0) then
|
||||
ATransformation := QtSmoothTransformation
|
||||
else
|
||||
ATransformation := QtFastTransformation;
|
||||
|
||||
QImage_scaled(ScaledImage, ScaledImage, LocalRect.Right - LocalRect.Left,
|
||||
LocalRect.Bottom - LocalRect.Top, QtIgnoreAspectRatio, QtSmoothTransformation);
|
||||
LocalRect.Bottom - LocalRect.Top, QtIgnoreAspectRatio, ATransformation);
|
||||
NewRect := sourceRect^;
|
||||
NewRect.Right := (LocalRect.Right - LocalRect.Left) + sourceRect^.Left;
|
||||
NewRect.Bottom := (LocalRect.Bottom - LocalRect.Top) + sourceRect^.Top;
|
||||
@ -3580,13 +3590,19 @@ begin
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
// smooth a bit. issue #29883
|
||||
ARenderHint := QPainter_testRenderHint(Widget, QPainterSmoothPixmapTransform);
|
||||
if (QImage_format(image) = QImageFormat_ARGB32) and (flags = QtAutoColor) and
|
||||
{smooth a bit. issue #29883
|
||||
check if antialiasing is on, if not then don''t call smoothTransform. issue #330011}
|
||||
|
||||
ARenderHints := QPainter_renderHints(Widget);
|
||||
ARenderHint := (ARenderHints and QPainterAntialiasing <> 0) or (ARenderHints and QPainterSmoothPixmapTransform <> 0) or
|
||||
(ARenderHints and QPainterHighQualityAntialiasing <> 0);
|
||||
|
||||
if ARenderHint and (QImage_format(image) = QImageFormat_ARGB32) and (flags = QtAutoColor) and
|
||||
not EqualRect(LocalRect, sourceRect^) then
|
||||
QPainter_setRenderHint(Widget, QPainterSmoothPixmapTransform, True);
|
||||
QPainter_drawImage(Widget, PRect(@LocalRect), image, sourceRect, flags);
|
||||
QPainter_setRenderHint(Widget, QPainterSmoothPixmapTransform, ARenderHint);
|
||||
if ARenderHint then
|
||||
QPainter_setRenderHint(Widget, QPainterSmoothPixmapTransform, not ARenderHint);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user