void BqtOglCanvas::drawImage(int width, int height, BmRect imageRect)
{
imgFlag = true;
resultSize
= QSize(width, height
);
paintRect
= QRect(QPoint(imageRect.
pnt1.
x, imageRect.
pnt1.
y),
QPoint(imageRect.
pnt2.
x, imageRect.
pnt2.
y));
}
image->load(fileName);
*image = image->scaled(resultSize, Qt::KeepAspectRatio);
return image;
}
QImage BqtOglCanvas
::getSourceImage() { return sourceImage;
}
{
if (imgFlag) {
imgFlag = false;
QImage sourceImage
= getSourceImage
();
QImage* img
= loadImage
("C:/Users/qu826e/Downloads/ply.png",
&sourceImage
);
const QRect imageRect
= paintRect;
painter.drawImage(imageRect, resImage);
}
}
void BqtOglCanvas::drawImage(int width, int height, BmRect imageRect)
{
imgFlag = true;
resultSize = QSize(width, height);
paintRect = QRect(QPoint(imageRect.pnt1.x, imageRect.pnt1.y), QPoint(imageRect.pnt2.x, imageRect.pnt2.y));
}
QImage* BqtOglCanvas::loadImage(const QString &fileName, QImage *image) {
image->load(fileName);
*image = image->scaled(resultSize, Qt::KeepAspectRatio);
return image;
}
QImage BqtOglCanvas::getSourceImage() {
return sourceImage;
}
void BqtOglCanvas::paintEvent(QPaintEvent *e)
{
if (imgFlag) {
imgFlag = false;
QImage sourceImage = getSourceImage();
QImage* img = loadImage("C:/Users/qu826e/Downloads/ply.png", &sourceImage);
const QRect imageRect = paintRect;
const QImage resImage = *img;
QPainter painter(this);
painter.drawImage(imageRect, resImage);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks