I have a directshow filter that I use to capture the screen using the code below.
First I get the window rect using
EnumWindows
this gives me lpRect
HDC hMemDC;
HBITMAP hBitmap, hOldBitmap;
int nX, nY, nX2, nY2;
int nWidth, nHeight;
if (IsRectEmpty(lpRect))
return NULL;
hMemDC = CreateCompatibleDC(hScrDC);
nX = lpRect->left;
nY = lpRect->top;
nX2 = lpRect->right;
nY2 = lpRect->bottom;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
hOldBitmap = (HBITMAP) SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
hBitmap = (HBITMAP) SelectObject(hMemDC, hOldBitmap);
GetDIBits(hScrDC, hRawBitmap, 0, nHeightScanLines, pData, pHeader, DIB_RGB_COLORS);
DeleteDC(hMemDC);
The problem is when I resize the window I'm trying to capture, it should look like this
However it ends up like this
I have a feeling it is due to the pixel count for the width of the image however I'm unsure how to resize the output width and height of the directshow filter?