在C ++中打开和显示图像? [英] Opening and Displaying an Image in C++?

查看:257
本文介绍了在C ++中打开和显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我教自己C ++和部分程序功能将打开和关闭指定的图像。我怎么会这样做?

解决方案

在c ++(没有任何额外的库),你可以打开一个图像。但除了一堆二进制数据,将没有perticularly有用。那么你必须使用自己的解码器。
如果您使用 opencv ,您可以写入以打开图片并显示:

  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 ++中打开和显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆