I have a PNG resource stored in a Windows exe. I want to load the png resource and create a pointer to the png data that can be written to disk to create a png file. (FWIW, I don't actually create the file at this point; the data is initially written inside another file and saved as a png file later.) This is in an MFC (c++) project, but the solution doesn't need to use MFC.
I envision a function prototype like this:
void GetPngFromResource(int iResourceID, VOID* pPngFileData, DWORD* pwPngDataBytes);
I see that ::LoadBitmap(), ::LoadImage() and CImage::LoadFromResource() don't support png resource loading. When I do attempt to use LoadImage(), GetLastError() reports "The specified resource name cannot be found in the image file" (error 1814):
HBITMAP hBitmapImage = (HBITMAP)::LoadImage(::GetModuleHandle(0), MAKEINTRESOURCE(iResourceID), IMAGE_BITMAP, 0, 0, 0);
I know the resource exists, because I can get a handle to it using FindResource() (although I don't know how, or whether it is possible, to get the png file data from the HRSCR handle):
HRSCR h = FindResource(HINST_THISCOMPONENT, MAKEINTRESOURCE(iResourceID), L"PNG");
I have seen examples that create an HBITMAP from a png resource using gdi+, but I need to end up with png file data.
Thanks!