Skip to content

Commit

Permalink
Scale large images in ImageViewer to fit the viewport by default
Browse files Browse the repository at this point in the history
  • Loading branch information
MKleusberg committed Jun 8, 2020
1 parent d653bf9 commit 23b1021
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ void ImageViewer::setImage(const QImage& image)
{
ui->labelView->setPixmap(QPixmap::fromImage(image));

// Reset the scaling to show the image in its original size
scaleImage(100);
// If the image is larger than the viewport scale it to fit the viewport.
// If the image is smaller than the viewport show it in its original size.
if(image.size().width() > ui->labelView->size().width() || image.size().height() > ui->labelView->size().height())
ui->buttonFitToWindow->setChecked(true);
else
scaleImage(100);
}

void ImageViewer::openPrintImageDialog()
Expand Down

0 comments on commit 23b1021

Please sign in to comment.