From b7a1bcd83a8f68185b617b860cef6f2d2d7c8d9b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 1 Jun 2018 11:08:59 +0200 Subject: Fix subrect of mismatched dpr sprite image Scale the subrect to fit image dpr. Task-number: QTBUG-68490 Task-number: QTBUG-68582 Change-Id: I6b0a9af73013dc6cf2b65103d5868f45da8e338e Reviewed-by: Mitch Curtis --- src/quick/items/qquickspriteengine.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp index 03f0fa94a4..be297bbe76 100644 --- a/src/quick/items/qquickspriteengine.cpp +++ b/src/quick/items/qquickspriteengine.cpp @@ -456,12 +456,12 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) QImage img(state->m_pix.image()); const int frameWidth = state->m_frameWidth; const int frameHeight = state->m_frameHeight; - const int imgHeight = img.height() / state->devicePixelRatio(); - const int imgWidth = img.width() / state->devicePixelRatio(); + const int imgHeight = img.height() / img.devicePixelRatioF(); + const int imgWidth = img.width() / img.devicePixelRatioF(); if (imgHeight == frameHeight && imgWidth < maxSize){ //Simple case p.drawImage(QRect(0, y, state->m_frames * frameWidth, frameHeight), img, - QRect(state->m_frameX * state->devicePixelRatio(), 0, state->m_frames * frameWidth * state->devicePixelRatio(), frameHeight * state->devicePixelRatio())); + QRect(state->m_frameX * img.devicePixelRatioF(), 0, state->m_frames * frameWidth * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); state->m_rowStartX = 0; state->m_rowY = y; y += frameHeight; @@ -478,7 +478,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) framesLeft -= copied/frameWidth; p.drawImage(QRect(x, y, copied, frameHeight), img, - QRect(curX * state->devicePixelRatio(), curY * state->devicePixelRatio(), copied * state->devicePixelRatio(), frameHeight * state->devicePixelRatio())); + QRect(curX * img.devicePixelRatioF(), curY * img.devicePixelRatioF(), copied * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); y += frameHeight; curX += copied; x = 0; @@ -491,7 +491,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) framesLeft -= copied/frameWidth; p.drawImage(QRect(x, y, copied, frameHeight), img, - QRect(curX * state->devicePixelRatio(), curY * state->devicePixelRatio(), copied * state->devicePixelRatio(), frameHeight * state->devicePixelRatio())); + QRect(curX * img.devicePixelRatioF(), curY * img.devicePixelRatioF(), copied * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); curY += frameHeight; x += copied; curX = 0; -- cgit v1.2.3