How to load an PNG resource from my resource file (winapi)

I create an resource file with Visual C++, and add into this file an PNG image resource, but I can`t load this from my application, I search an function such as LoadBitmap or another metod, but I have cero results. Please answer, thanks.
You need to use a library (like libPNG http://www.libpng.org/pub/png/libpng.html ) to read PNG data. (You could write your own, too, if you wanted...)

Open the resource as an RCDATA resource type -- that's for binary data -- and then transform it using the PNG library.

Hope this helps.
yes.. you will use LoadBitmap for laoding a bitmap or jped or png resource from your resource file.
but i think LoadBitmap i also takes hinstance of the application and i think you might be doing a mistake there..

for that you can do :
(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);

this will give you instance of the application.. LoadBitmap will give you the handle of the bitmap.

but what exactly you want to do .. and it will be better if you post your code.
LoadBitmap has nothing to do with png
You don't need any library.
Just use gdi+
You do realize that GDI+ is a library?

Also, you are aware that the most recent versions of Windows accept JPG and PNG formatted data as an extension to BMP resources, right? [edit] Argh... but only for StretchDIBits() and the like when the target is a printer. [/edit]

That said, GDI+ is also a very useful option, and you should have access to it with VC++.
Last edited on
> You do realize that GDI+ is a library?

No, it's a native DLL, not an external library...
LoadBitmap () doesn't load JPG or PNG (!!!!)
closed account (z05DSL3A)
DLL = Dynamic Link Library, does it not?
> LoadBitmap () doesn't load JPG or PNG (!!!!)

Yes, sigh, you are right. I was convinced otherwise by listening to Vista hype, and mis-reading the MSDN nonsense documentation.

So to load a PNG resource, you need to use a library like libPNG or GDI+, or write your own reader...


@Grey Wolf
By "external library" I think that george means 'that which is not made by Microsoft'... ;-)
I wonder if he considers the standard libraries of non-MS compilers as "external libraries". What about languages other than C/++? What about drivers?
Topic archived. No new replies allowed.