JFJochMagnifierWindow: Zoom is saved ... it is not optimal (when image is first loaded, than it starts with weird zoom), but can be fixed later

This commit is contained in:
2026-06-09 12:03:45 +02:00
parent 5735302691
commit 30dcc98f89
3 changed files with 19 additions and 2 deletions
+13
View File
@@ -948,4 +948,17 @@ void JFJochImage::adjustForeground(bool input) {
void JFJochImage::beforeOverlayCleared() {}
double JFJochImage::GetScaleFactor() const {
return scale_factor;
}
void JFJochImage::setZoom(double input) {
if (std::isfinite(input) && input > 0) {
scale_factor = input;
if (!scene())
return;
scale(input, input);
updateOverlay();
emitViewportChanged();
}
}
+2 -1
View File
@@ -131,7 +131,8 @@ public slots:
void fitToView();
void adjustForeground(bool input);
void setZoom(double input);
public:
explicit JFJochImage(QWidget *parent = nullptr);
double GetScaleFactor() const;
};
+4 -1
View File
@@ -11,6 +11,7 @@ JFJochMagnifierWindow::JFJochMagnifierWindow(QWidget *parent)
: JFJochHelperWindow(parent) {
setWindowTitle("Magnifier");
m_image = new JFJochSimpleImage(this);
m_image->setZoom(m_magnification);
setCentralWidget(m_image);
resize(320, 320);
}
@@ -25,11 +26,13 @@ void JFJochMagnifierWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage>
auto si = std::make_shared<SimpleImage>();
si->image = CompressedImage(image->Image(), exp.GetXPixelsNum(), exp.GetYPixelsNum());
m_image->setImage(si);
m_image->setZoom(m_magnification);
m_have_image = true;
}
void JFJochMagnifierWindow::centerAt(QPointF scenePos) {
if (!m_have_image || !isVisible())
return;
m_image->applyViewport(QTransform::fromScale(m_magnification, m_magnification), scenePos);
double scale = m_image->GetScaleFactor();
m_image->applyViewport(QTransform::fromScale(scale, scale), scenePos);
}