Why this error happens and how to remove the problem?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
RECT rect; GetWindowRect(HCapture, &rect);
size_t dx = rect.right - rect.left;
size_t dy = rect.bottom - rect.top;
BITMAPINFO info = {0};
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info.bmiHeader.biWidth = dx;
info.bmiHeader.biHeight = dy;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24;
info.bmiHeader.biCompression = BI_RGB;
/*info.bmiHeader.biSizeImage = 0;
info.bmiHeader.biXPelsPerMeter = 0;
info.bmiHeader.biYPelsPerMeter = 0;
info.bmiHeader.biClrUsed = 0;
info.bmiHeader.biClrImportant = 0;*/
HBITMAP HBitmap = 0;
BYTE* memory = 0; // ppvBits - A pointer to a variable that will receive a pointer to the location of the DIB bit values. See CreateDIBSection()
HDC HDevice = CreateCompatibleDC(NULL);
HBitmap = CreateDIBSection(HDevice, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);
DWORD dw = GetLastError();
|
CreateDIBSection caused error:
ERROR_NOT_ENOUGH_MEMORY
8 (0x8)
Not enough storage is available to process this command.
Last edited on
I also tryed
HBitmap = CreateDIBSection(HDevice, &info, DIB_RGB_COLORS, (void**)&memory, NULL, NULL);
According manual:
HBITMAP CreateDIBSection(
_In_ HDC hdc,
_In_ const BITMAPINFO *pbmi,
_In_ UINT iUsage,
_Out_ VOID **ppvBits,
_In_ HANDLE hSection,
_In_ DWORD dwOffset
);
"If hSection is NULL, the system allocates memory for the DIB. In this case, the CreateDIBSection function ignores the dwOffset parameter."
Hence it makes no no sence to me why not enough memory.
Last edited on
I found that my program works even that there is the error 8. It does the same in the original program to capture visible window content.