summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-07-05 18:06:54 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-07-06 10:47:32 +0200
commit30bf6b73178a6cf793cddb9c646560808f5faba7 (patch)
tree976b1dbe8f574d04607559fad4511f2be840757e /vcl
parentef46981023becba0f34a235a3571028dd0ea8838 (diff)
Qt5 implement scaled image draws
If the source and target rects don't match, LO expect the image to be scaled. Change-Id: I337acfa56600eba92c10aed7a70749ad08c03e90
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/Qt5Graphics.hxx2
-rw-r--r--vcl/qt5/Qt5Graphics_GDI.cxx43
2 files changed, 20 insertions, 25 deletions
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index 0e9de46818a6..b1ba6ce85d98 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -53,6 +53,8 @@ class Qt5Graphics : public SalGraphics
Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage);
+ void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
+
public:
Qt5Graphics(Qt5Frame* pFrame)
: Qt5Graphics(pFrame, nullptr)
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index 971b85f705fe..08c620c11796 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -356,6 +356,15 @@ bool Qt5Graphics::drawPolyLine(const basegfx::B2DPolygon& rPolyLine, double fTra
bool Qt5Graphics::drawGradient(const tools::PolyPolygon&, const Gradient&) { return false; }
+void Qt5Graphics::drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage)
+{
+ Qt5Painter aPainter(*this);
+ QRect aSrcRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight);
+ QRect aDestRect(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
+ aPainter.drawImage(aDestRect, rImage, aSrcRect);
+ aPainter.update(aDestRect);
+}
+
void Qt5Graphics::copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
long nSrcHeight, bool /*bWindowInvalidate*/)
{
@@ -372,25 +381,21 @@ void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics)
|| rPosAry.mnDestHeight <= 0)
return;
- assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth);
- assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight);
-
- QImage aImage, *pImage = &aImage;
+ QImage aImage, *pImage;
+ SalTwoRect aPosAry = rPosAry;
if (!pSrcGraphics || this == pSrcGraphics)
{
- if (rPosAry.mnDestX == rPosAry.mnSrcX && rPosAry.mnDestY == rPosAry.mnSrcY)
- return;
+ pImage = static_cast<Qt5Graphics*>(this)->m_pQImage;
aImage
= pImage->copy(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight);
+ pImage = &aImage;
+ aPosAry.mnSrcX = 0;
+ aPosAry.mnSrcY = 0;
}
else
pImage = static_cast<Qt5Graphics*>(pSrcGraphics)->m_pQImage;
- Qt5Painter aPainter(*this);
- aPainter.drawImage(
- QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage,
- QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
- aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
+ drawScaledImage(aPosAry, *pImage);
}
void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap)
@@ -399,10 +404,6 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit
|| rPosAry.mnDestHeight <= 0)
return;
- assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth);
- assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight);
-
- Qt5Painter aPainter(*this);
Qt5Bitmap aRGBABitmap;
if (rSalBitmap.GetBitCount() == 4)
aRGBABitmap.Create(rSalBitmap, 32);
@@ -411,10 +412,7 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit
: aRGBABitmap.GetQImage();
assert(pImage);
- aPainter.drawImage(
- QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage,
- QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
- aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
+ drawScaledImage(rPosAry, *pImage);
}
void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& /*rSalBitmap*/,
@@ -523,12 +521,7 @@ bool Qt5Graphics::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBitmap& rS
QImage aImage;
if (!getAlphaImage(rSourceBitmap, rAlphaBitmap, aImage))
return false;
-
- Qt5Painter aPainter(*this);
- aPainter.drawImage(
- QPoint(rPosAry.mnDestX, rPosAry.mnDestY), aImage,
- QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
- aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
+ drawScaledImage(rPosAry, aImage);
return true;
}