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
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 ofQt,wxWidgetsand the like, working with.pngand rendering is done by the library itself, however, it is clear that the methods are very different.In the case of
WinAPIit makes sense to read this image usinglibpngto some buffer and draw it from the buffer in theWM_PAINThandler.When using
C++ Builderenvironment, everything is done using theVCLTImageclass.
- 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/ms535370Image::FromFile()v = VS.85Image::FromFile().aspx - AlexeyM - strangely, I connected GDI + using Image :: FromFile (), when compiling it writes a bunch of errors with winbase.h - xPlayerAdv
|