I have a pure C++/Win32 VS2005 desktop application. During my WM_PAINT response, when I paint my window, I'd like to be able to Project a transparent PNG image onto my Window.
any pointer will be appreciated.
The Windows Imaging Component (WIC) is the primary API for native code that provides the ability to encode and decode various image formats. You can use it to load a PNG image into your application.
http://msdn.microsoft.com/library/ee719902
Alternatively you can use GDI+ but that’s pretty old technology and doesn’t work nearly as well. You can also use GDI+ to render the image but I suggest Direct2D.
Direct2D is capable of rendering a WIC bitmap directly on the GPU or in software via a window or bitmap device context.
Here’s an introductory article on Direct2D:
http://msdn.microsoft.com/en-ca/magazine/dd861344.aspx
And this one describes how to use Direct2D with WIC:
http://msdn.microsoft.com/en-us/magazine/ee819134.aspx
GdiPlus has been part of Windows since Windows XP at least, and can decode JPEG, PNG and GIF files with ease.
A newer API for dealing with image files is the Windows Image Component. One of the samples covers using WIC to decode an image and GdiPlus to perform the alpha aware painting.
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