first commit

This commit is contained in:
2026-04-29 14:10:10 +08:00
commit b28556d43d
1558 changed files with 241386 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "ImagePreviewer.h"
#include <QPainter>
ImagePreviewer::ImagePreviewer(QWidget *parent) : QWidget(parent)
{
}
void ImagePreviewer::setImg(QImage img)
{
m_img = img;
repaint();
}
void ImagePreviewer::paintEvent(QPaintEvent* event)
{
QPainter p(this);
// p.fillRect(rect(), QBrush(QColor(199, 237, 202)));
QRectF d = rect();
QSizeF s = m_img.size();
if(d.width() <= s.width() * m_maxScaleMultiple || d.height() <= s.height() * m_maxScaleMultiple) {
d.setSize(s.scaled(d.size(), Qt::KeepAspectRatio));
}
else {
d.setWidth(s.width() * m_maxScaleMultiple);
d.setHeight(s.height() * m_maxScaleMultiple);
}
d.moveCenter(rect().center());
p.drawImage(d, m_img);
}