dprasad
asked on
Limiting size of screen capture, using GDI from C#
Hi.
I am calling the method to capture the entire screen. The issue is that I want to only capture only a thin slice of the desktop as a screenshot, the rest of it is meaningless. Any suggestions on how I can specify the coordinates that should be capture? Thanks
public static void CaptureScreen(string fileName, ImageFormat imageFormat)
{
int hdcSrc = User32.GetWindowDC(User32. GetDesktop Window()),
hdcDest = GDI32.CreateCompatibleDC(h dcSrc),
hBitmap = GDI32.CreateCompatibleBitm ap(hdcSrc,
GDI32.GetDeviceCaps(hdcSrc , 8), GDI32.GetDeviceCaps(hdcSrc , 10)); GDI32.SelectObject(hdcDest , hBitmap);
GDI32.BitBlt(hdcDest, 0, 0, GDI32.GetDeviceCaps(hdcSrc , 8),
GDI32.GetDeviceCaps(hdcSrc , 10), hdcSrc, 0, 0, 0x00CC0020);
SaveImageAs(hBitmap, fileName, imageFormat);
Cleanup(hBitmap, hdcSrc, hdcDest);
}
I am calling the method to capture the entire screen. The issue is that I want to only capture only a thin slice of the desktop as a screenshot, the rest of it is meaningless. Any suggestions on how I can specify the coordinates that should be capture? Thanks
public static void CaptureScreen(string fileName, ImageFormat imageFormat)
{
int hdcSrc = User32.GetWindowDC(User32.
hdcDest = GDI32.CreateCompatibleDC(h
hBitmap = GDI32.CreateCompatibleBitm
GDI32.GetDeviceCaps(hdcSrc
GDI32.BitBlt(hdcDest, 0, 0, GDI32.GetDeviceCaps(hdcSrc
GDI32.GetDeviceCaps(hdcSrc
SaveImageAs(hBitmap, fileName, imageFormat);
Cleanup(hBitmap, hdcSrc, hdcDest);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.