我想以“函数式”编程风格显示图像。基本上,我对我的图像进行了许多处理,有时我想显示结果。所以我正在尝试:
int display(string file, int argc, char *argv[])
{
QApplication a1(argc,argv);
QImage myImage;
myImage.load(file.c_str());
QLabel myLabel;
myLabel.setPixmap(QPixmap::fromImage(myImage));
myLabel.show();
return a1.exec();
}
int main(int argc, char *argv[])
{
MyImageDataStructure img;
img.erosion(5);//process 1
img.save("lenaero.png");
display("lenaeor.png",argc,argv); // display the first result
img.dilation(5);//process 2
img.save("lenaopening.png");
display("lenaopening.png",argc,argv); // display the second result
return 1;
}
但在第二次执行显示功能时,出现错误。你有什么想法可以在保持这个逻辑的同时解决这个问题吗?
谢谢
注意:我不想包含除 Qt 之外的外部库,并且我知道我想在 Qt 逻辑之外工作。