Good Morning All,
My app deals with burrowing down to the R G B pixel data in successive video frames. The frame analysis takes place in a dialog where method ShowFrame renders a zoomed QPixmap to screen.
My problem is I cannot get the QPainter to zoom the pixmap.
void IconDialog
::ShowFrame(QString aFrameNm,
int Zoom
) {
FrameNm = aFrameNm;
scene->clear();
Frame.load(aFrameNm);
scene->setSceneRect(Frame.rect());
if (Zoom > 1) {
QRectF sr
= pixmap.
rect();
//source rectangle int w = qRound(sr.width()/Zoom);
int h = qRound(sr.height()/Zoom);
tr.setX(sr.width()-w);
tr.setY(sr.height()-h);
tr.setWidth(w);
tr.setHeight(h);
if (p.begin(this)) {
p.drawPixmap(tr, pixmap, sr);
p.end();
}
else {
QMessageBox::information(0,
"Error IconDialog",
"Statement p.begin(this) failed, I don't know why.");
}
}
scene->addItem(item);
ui->FrameGV->show();
}
void IconDialog::ShowFrame(QString aFrameNm, int Zoom)
{
QGraphicsPixmapItem *item;
FrameNm = aFrameNm;
scene->clear();
Frame.load(aFrameNm);
scene->setSceneRect(Frame.rect());
QPixmap pixmap = QPixmap::fromImage(Frame);
if (Zoom > 1) {
QRectF sr = pixmap.rect(); //source rectangle
int w = qRound(sr.width()/Zoom);
int h = qRound(sr.height()/Zoom);
QRectF tr; //target rectangle
tr.setX(sr.width()-w);
tr.setY(sr.height()-h);
tr.setWidth(w);
tr.setHeight(h);
QPainter p;
if (p.begin(this)) {
p.drawPixmap(tr, pixmap, sr);
p.end();
}
else {
QMessageBox::information(0, "Error IconDialog", "Statement p.begin(this) failed, I don't know why.");
}
}
item = new QGraphicsPixmapItem(pixmap);
scene->addItem(item);
ui->FrameGV->show();
}
To copy to clipboard, switch view to plain text mode
What ever I try results in activating the QMessageBox, I cannot find a "last error" or a reason for failure.
I have followed the usual procedures to resolve the issue but without success.
I believe my code is at fault, I have missed something, but what?
Hope you can help.
Thank you.
Regards
Glen
Bookmarks