How to import a picture with the .png format into a program (written in C ++) and display it? If possible, provide an example.

    1 answer 1

    One possible way is to read this very picture using libpng.

    • In general, the question is very dependent on the tools used to draw Gui . In the case of Qt , wxWidgets and the like, working with .png and rendering is done by the library itself, however, it is clear that the methods are very different.

    • In the case of WinAPI it makes sense to read this image using libpng to some buffer and draw it from the buffer in the WM_PAINT handler.

    • When using C++ Builder environment, everything is done using the VCL TImage class.

    • You can give an example of how to read a picture using libpng , and then when you try to compile it writes a bunch of errors. - xPlayerAdv
    • If WinAPI is used, then it’s easier to use Image::FromFile() msdn.microsoft.com/en-us/library/ms535370 Image::FromFile() v = VS.85 Image::FromFile() .aspx - AlexeyM
    • strangely, I connected GDI + using Image :: FromFile (), when compiling it writes a bunch of errors with winbase.h - xPlayerAdv