I downloaded this code from the internet and got the following compile error from Microsoft Visual Studio Community 2017:
Error C2664 'HBITMAP CreateDIBSection(HDC,const BITMAPINFO *,UINT,void **,HANDLE,DWORD)':
cannot convert argument 2 from 'const BITMAPINFO *' to 'const BITMAPINFO *'
How do I solve this?
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER BitMapInfoHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
char * abMyBitmap = new char[sizeof(BITMAPINFOHEADER) + 100 * 100 * 4]; // ?? todo check this
const BITMAPINFO * pBitMap = (BITMAPINFO*)abMyBitmap;
HBITMAP hBitmap;
VOID * pvBits;
hBitmap = CreateDIBSection( NULL, pBitMap, DIB_RGB_COLORS, &pvBits, NULL, NULL );
Why you are re-defining BITMAPINFO
? It is already defined in wingdi.h
. Remove your typedef
, and your code will compile fine.