Merge pull request #62 from YACReader/feature/magnifying_glass_fixes

Feature/magnifying glass fixes
This commit is contained in:
Luis Ángel San Martín 2019-06-01 16:12:53 +02:00 committed by GitHub
commit d459056615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,14 +77,15 @@ void MagnifyingGlass::updateImage(int x, int y)
} }
if (outImage) { if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.setDevicePixelRatio(devicePixelRatio());
img.fill(Configuration::getConfiguration().getBackgroundColor()); img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) { if (zw > 0 && zh > 0) {
QPainter painter(&img); QPainter painter(&img);
painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh)); painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh));
} }
setPixmap(QPixmap().fromImage(img)); setPixmap(QPixmap().fromImage(img));
} else } else
setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight)); setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight));
} else { } else {
int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2); int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
int yp = static_cast<int>((y + currentPos) * hFactor - zoomHeight / 2); int yp = static_cast<int>((y + currentPos) * hFactor - zoomHeight / 2);
@ -117,14 +118,15 @@ void MagnifyingGlass::updateImage(int x, int y)
} }
if (outImage) { if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.setDevicePixelRatio(devicePixelRatio());
img.fill(Configuration::getConfiguration().getBackgroundColor()); img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) { if (zw > 0 && zh > 0) {
QPainter painter(&img); QPainter painter(&img);
painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh)); painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh));
} }
setPixmap(QPixmap().fromImage(img)); setPixmap(QPixmap().fromImage(img));
} else } else
setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight)); setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight));
} }
move(static_cast<int>(x - float(width()) / 2), static_cast<int>(y - float(height()) / 2)); move(static_cast<int>(x - float(width()) / 2), static_cast<int>(y - float(height()) / 2));
} }