Qt,Qt5: copy proper mask size in StretchMaskBlt

git-svn-id: trunk@62877 -
This commit is contained in:
zeljko 2020-04-04 07:40:41 +00:00
parent 14d2b6e153
commit d78f0bd224
2 changed files with 25 additions and 34 deletions

View File

@ -6873,29 +6873,25 @@ var
else else
QPixmap_copy(APixmap, ATempPixmap, 0, 0, QPixmap_width(APixmap), QPixmap_height(APixmap)); QPixmap_copy(APixmap, ATempPixmap, 0, 0, QPixmap_width(APixmap), QPixmap_height(APixmap));
if AMaskImg <> nil then if AMaskImg <> nil then
begin begin
// apply mask to pixmap // apply mask to pixmap
AScaledPix := nil; AScaledPix := QPixmap_create();
AMaskPix := QPixmap_create(); AMaskPix := QPixmap_create();
QPixmap_fromImage(AMaskPix, AMaskImg); QPixmap_fromImage(AMaskPix, AMaskImg);
try try
if NeedScaling(DstRect, SrcRect) then
begin if IsRectEmpty(MaskRect) then
AScaledPix := QPixmap_create(); QPixmap_copy(AMaskPix, AScaledPix, 0, 0, Min(Width, QPixmap_Width(AMaskPix)), Min(Height, QPixmap_Height(AMaskPix)) )
QPixmap_scaled(AMaskPix, AScaledPix, Width, Height); else
QPixmap_copy(AMaskPix, AScaledPix, MaskRect.Left, MaskRect.Top,
MaskRect.Right - MaskRect.Left, MaskRect.Bottom - MaskRect.Top);
ABitmap := QBitmap_Create(AScaledPix); ABitmap := QBitmap_Create(AScaledPix);
end else
if (Width <> SrcWidth) or (Height <> SrcHeight) then
begin
AScaledPix := QPixmap_create();
QPixmap_copy(AMaskPix, AScaledPix, 0, 0, Width, Height);
ABitmap := QBitmap_Create(AScaledPix);
end else
ABitmap := QBitmap_Create(AMaskPix);
QPixmap_setMask(ATempPixmap, ABitmap); QPixmap_setMask(ATempPixmap, ABitmap);
QBitmap_Destroy(ABitmap); QBitmap_Destroy(ABitmap);
if AScaledPix <> nil then
QPixmap_destroy(AScaledPix); QPixmap_destroy(AScaledPix);
finally finally
QPixmap_destroy(AMaskPix); QPixmap_destroy(AMaskPix);
@ -6978,7 +6974,7 @@ begin
QImage_copy(SrcQDC.vImage.Handle, TmpImage, XSrc, YSrc, SrcWidth, SrcHeight); QImage_copy(SrcQDC.vImage.Handle, TmpImage, XSrc, YSrc, SrcWidth, SrcHeight);
// #11713, #25590 // #11713, #25590
if (QMask = nil) and (QImage_format(TmpImage) = QImageFormat_RGB32) then if (QImage_format(TmpImage) = QImageFormat_RGB32) then
begin begin
Image := QImage_create(); Image := QImage_create();
QImage_convertToFormat(TmpImage, Image, QImageFormat_ARGB32); QImage_convertToFormat(TmpImage, Image, QImageFormat_ARGB32);

View File

@ -6821,26 +6821,21 @@ var
if AMaskImg <> nil then if AMaskImg <> nil then
begin begin
// apply mask to pixmap // apply mask to pixmap
AScaledPix := nil; AScaledPix := QPixmap_create();
AMaskPix := QPixmap_create(); AMaskPix := QPixmap_create();
QPixmap_fromImage(AMaskPix, AMaskImg); QPixmap_fromImage(AMaskPix, AMaskImg);
try try
if NeedScaling(DstRect, SrcRect) then
begin if IsRectEmpty(MaskRect) then
AScaledPix := QPixmap_create(); QPixmap_copy(AMaskPix, AScaledPix, 0, 0, Min(Width, QPixmap_Width(AMaskPix)), Min(Height, QPixmap_Height(AMaskPix)) )
QPixmap_scaled(AMaskPix, AScaledPix, Width, Height); else
QPixmap_copy(AMaskPix, AScaledPix, MaskRect.Left, MaskRect.Top,
MaskRect.Right - MaskRect.Left, MaskRect.Bottom - MaskRect.Top);
ABitmap := QBitmap_Create(AScaledPix); ABitmap := QBitmap_Create(AScaledPix);
end else
if (Width <> SrcWidth) or (Height <> SrcHeight) then
begin
AScaledPix := QPixmap_create();
QPixmap_copy(AMaskPix, AScaledPix, 0, 0, Width, Height);
ABitmap := QBitmap_Create(AScaledPix);
end else
ABitmap := QBitmap_Create(AMaskPix);
QPixmap_setMask(ATempPixmap, ABitmap); QPixmap_setMask(ATempPixmap, ABitmap);
QBitmap_Destroy(ABitmap); QBitmap_Destroy(ABitmap);
if AScaledPix <> nil then
QPixmap_destroy(AScaledPix); QPixmap_destroy(AScaledPix);
finally finally
QPixmap_destroy(AMaskPix); QPixmap_destroy(AMaskPix);
@ -6923,7 +6918,7 @@ begin
QImage_copy(SrcQDC.vImage.Handle, TmpImage, XSrc, YSrc, SrcWidth, SrcHeight); QImage_copy(SrcQDC.vImage.Handle, TmpImage, XSrc, YSrc, SrcWidth, SrcHeight);
// #11713, #25590 // #11713, #25590
if (QMask = nil) and (QImage_format(TmpImage) = QImageFormat_RGB32) then if (QImage_format(TmpImage) = QImageFormat_RGB32) then
begin begin
Image := QImage_create(); Image := QImage_create();
QImage_convertToFormat(TmpImage, Image, QImageFormat_ARGB32); QImage_convertToFormat(TmpImage, Image, QImageFormat_ARGB32);