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 particularly useful except a bunch of binary data. then you have to use your own decoder If you use opencv you can write to open an image and display it:
Mat m("fileName");
imshow("windowName",m);
To do the same with a general purpose 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.
For a crossplatform, opensource and very good library you can use libmagick++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With