Is it possible to load a PNG from a file into an HBITMAP using Win32 GDI functions? If not, what would be the lightest solution without using external libraries (like libpng)?
相关问题
- Views base64 encoded blob in HTML with PHP
- Sorting 3 numbers without branching [closed]
- How to get the background from multiple images by
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- Use savefig in Python with string and iterative in
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
You can do it with
StretchDIBits
API, but limited by OS/driver availability.Consult MSDN documentation for details:
http://msdn.microsoft.com/en-us/library/dd145121(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/dd145107(VS.85).aspx
I sincerely apologize for misleading you guys interested in this issue. Let me correct my mistake. No
StretchDIBits
for PNG drawing. You'd better try WIC method or consider way to integrate GDI+ in your projects.You can use the Windows Imaging Component to load PNG files (on Windows XP SP2 and later). See MSDN Magazine for an introduction on how to use the API and my blog post for a code sample that loads a PNG from an IStream and converts it to an HBITMAP.
There is no need to use Windows Imaging Component, GDI+ or PNG library. You can use Icon functionality.
Add new icon (ICO_PNG) to VC project resources with custom Width and Height (Resource Editor->Image->New Image Type). Copy Your png image here and use Fill Tool+transparent color to make icon transparent.
Add Picture Control (IDC_PNG) to Your dialog (Type = Owner draw).
Dialog procedure code:
Don't think GDI supports png, have you looked at libpng