I've implemented a simple screenshot capture method, where I do the following:
- Get the screen DC by calling GetDC (NULL);
- Use CreateCompatibleDC () to create a device context.
- Grab width/height of the screen by calling GetDeviceCaps ().
- Calling CreateCompatibleBitmap (screenDC, width, height);
- Calling SelectObject (deviceContext, bitmap);
- Finally, calling BitBlt (deviceContext, 0, 0, x, y, screenDC, 0, 0, SRCCOPY | CAPTUREBLT); and GetDIBits () to get the data pointer.
This works fine except that it doesn't work in odd resolutions like 1366x768 where everything shows up as white/black lines. Anyone got any ideas what's causing this? Is the data output from GetDIBits() padded in this case or something? It looks like there's an extra byte per channel or something which distorts the image as I'm assuming 32-bit, but that's hardly the case as the image is 32-bit.
Any advice is greatly appreciated!