Date: 2008jul12
Platform: GDI+
Language: C++
Q. How do I load a resource bitmap into a GDI+ bitmap?
A. Use this function:
Bitmap *ResourceToBitmap(const HINSTANCE hInstance, const int id)
{
HBITMAP hBmp = ::LoadBitmap(hInstance, MAKEINTRESOURCE(id));
if (bBmp == NULL) return NULL;
return Bitmap::FromHBITMAP(hBmp, NULL);
}
void ExampleUse()
{
Bitmap *pBitmap;
pBitmap = ResourceToBitmap(AfxGetInstanceHandle(), IDB_MY_BITMAP);
printf("Size is %d x %d\n", pBitmap->GetWidth(), pBitmap->GetHeight());
}
| What this info useful to you? You can donate to say thanks |
Add a comment
Sign in to add a comment