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
,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 usinglibpng
to some buffer and draw it from the buffer in theWM_PAINT
handler.When using
C++ Builder
environment, everything is done using theVCL
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/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
|