views:

34

answers:

1

Hi,

I am trying to create Cursor from png, and CreateDIBSection() is throwing.

Follwoing is the snippet of code:

HDC hdc = GetDC(NULL);
void* lpBits = NULL;
HBITMAP  hBitmap;
try
{
 hBitmap = CreateDIBSection(
  hdc,
  (BITMAPINFO*)&bi,
  0,
  &lpBits,
  NULL,
  (DWORD)0);
}

ReleaseDC(NULL, hdc);

As CreateDIBSection is throwing, the code to release DC is not getting executed. can you please let me know the possible issue behind this?

A: 

You should make structure zeroed out:

ZeroMemory(&bi,sizeof(BITMAPV5HEADER));

Try out this link , it may help you :

http://support.microsoft.com/kb/318876

Ashish