2022-01-04 18:11:48 +08:00
|
|
|
#include "pixbmpshowdialog.h"
|
|
|
|
#include "ui_pixbmpshowdialog.h"
|
|
|
|
#include <QPainter>
|
|
|
|
PixbmpShowDialog::PixbmpShowDialog(QWidget *parent) :
|
2022-08-25 18:37:24 +08:00
|
|
|
BaseDlg(parent),
|
2022-01-04 18:11:48 +08:00
|
|
|
ui(new Ui::PixbmpShowDialog)
|
|
|
|
{
|
2022-08-25 18:37:24 +08:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
ui->setupUi(this);
|
2022-01-04 18:11:48 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PixbmpShowDialog::~PixbmpShowDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
void PixbmpShowDialog::ResizeByPixmap(int w,int h)
|
|
|
|
{
|
|
|
|
m_iWidth=w;
|
|
|
|
m_iHeight=h;
|
|
|
|
int iWidth=w;
|
|
|
|
int iHeight=h;
|
|
|
|
if(iWidth<rect().width()&&iHeight<rect().height())
|
|
|
|
this->resize(iWidth,iHeight);
|
|
|
|
else {
|
|
|
|
if(iWidth>iHeight)
|
|
|
|
this->resize(rect().height()*iWidth/iHeight,rect().height());
|
|
|
|
else
|
|
|
|
this->resize(rect().width(),rect().width()*iHeight/iWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void PixbmpShowDialog::paintEvent(QPaintEvent * event)
|
|
|
|
{
|
|
|
|
Q_UNUSED(event);
|
|
|
|
QPainter painter(this);
|
|
|
|
//painter.eraseRect(rect());
|
|
|
|
// painter.scale(m_PixMap.width(), m_PixMap.height());
|
|
|
|
QRectF sourceRt(0,0,m_iWidth,m_iHeight);
|
|
|
|
painter.drawPixmap(rect(), m_PixMap,sourceRt);
|
|
|
|
|
|
|
|
}
|