问题描述
基本上我教自己C ++和部分程序功能将打开和关闭指定的图像。我怎么会这样做?
在c ++(没有任何额外的库),你可以打开一个图像。但除了一堆二进制数据,将没有perticularly有用。那么你必须使用自己的解码器。
如果您使用,您可以写入以打开图片并显示:
Mat m(fileName);
imshow(windowName,m);
要像qt这样的通用类库,你可以使用这个代码:
int main(int argc,char * argv [])
{
QApplication a(argc,argv);
QGraphicsScene scene;
QGraphicsView视图(& scene);
QGraphicsPixmapItem item(QPixmap(c:\\test.png));
scene.addItem(& item);
view.show();
return a.exec();
}
要了解有关imageviewer小部件的更多信息,请转到。或者,您可以查看以显示为图形视图。
Basically I am teaching myself C++ and part of the program function will be to open and close an image specified. How would I go about doing this? Or what resource would I use?
Thanks!
In c++ (without any extra library) you may open an image. But there will be nothing perticularly useful except a bunch of binary data. then you have to use your own decoder.If you use opencv you can write to open a image and display it:
Mat m("fileName");
imshow("windowName",m);
To do the same with a general perpouse library like qt you can use this code :
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
QGraphicsPixmapItem item(QPixmap("c:\\test.png"));
scene.addItem(&item);
view.show();
return a.exec();
}
To learn more about imageviewer widget go here. Or you may have a look at here to display as graphics view.
这篇关于在C ++中打开和显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!