I am using GDI++, but..

Hi. I got a problem using GDI++.

I succeeded loading a "png" image and displaying this on the window with this construction.

Image image(L"test.png");

however, I want to load image with the ID (I mean from resource) like kind of this. (I googled it)

HRSRC hResource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_PNG1), TEXT("PNG"));

if(!hResource) return;

DWORD imageSize = SizeofResource(AfxGetApp()->m_hInstance, hResource);
HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hResource);
LPVOID pData = LockResource(hGlobal);

HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, imageSize);
LPVOID pBuffer = GlobalLock(hBuffer);

IStream *pStream;
HRESULT hr = CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);

Image imagePng(pStream);


if(imagePng.GetLastStatus() != Ok) return;
graphics.DrawImage(&imagePng, 500,500,imagePng.GetWidth(),imagePng.GetHeight());

but, the variable "pStream" has nothing(looks like NULL)

What's the problem??

Topic archived. No new replies allowed.