Could the QImage image object be the problem?
I think after I load the file using the below code, the image object somehow gets destroyed after the function. What do you think?
void MainWindow::open()
{
QString fileName
= QFileDialog::getOpenFileName(this,tr
("Open File"),
QDir::currentPath(), tr
("Image Files (*.jpg *.jpeg *.bmp *.gif *.png)"));
if (!fileName.isEmpty()) {
if (image.isNull()) {
QMessageBox::critical(this, tr
("Image View"), tr
("Cannot load %1.").
arg(fileName
));
return;
}
imageLabel
->setPixmap
(QPixmap::fromImage(image
));
scaleFactor = 1.0;
closeAction->setEnabled(true);
imageLabel->adjustSize();
imagelabFile.convertToRGBImage(image); //If loading is ok, create an imagelabfile copy of the QImage
brightnessAction->setEnabled(true);
QMessageBox::information(this, tr
("Successful Conversion"),tr
("ImageLab image loaded. Ready for processing."));
}
}
void MainWindow::open()
{
QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath(), tr("Image Files (*.jpg *.jpeg *.bmp *.gif *.png)"));
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Image View"), tr("Cannot load %1.").arg(fileName));
return;
}
imageLabel->setPixmap(QPixmap::fromImage(image));
scaleFactor = 1.0;
closeAction->setEnabled(true);
imageLabel->adjustSize();
imagelabFile.convertToRGBImage(image); //If loading is ok, create an imagelabfile copy of the QImage
brightnessAction->setEnabled(true);
QMessageBox::information(this, tr("Successful Conversion"),tr("ImageLab image loaded. Ready for processing."));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks