:
/// <summary>
/// Saves a picture of the screen to a bitmap image.
/// </summary>
/// <returns>The saved bitmap.</returns>
private Bitmap CaptureScreenShot()
{
// get the bounding area of the screen containing (0,0)
// remember in a multidisplay environment you don't know which display holds this point
Rectangle bounds = Screen.GetBounds(Point.Empty);
// create the bitmap to copy the screen shot to
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
// now copy the screen image to the graphics device from the bitmap
using (Graphics gr = Graphics.FromImage(bitmap))
{
gr.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
return bitmap;
}
을 그리고 이미지의 부분을 아마 마우스 위치를 중심으로 50 픽셀 사각형하여 50 픽셀 :
portionOf = bitmap.Clone(new Rectangle(pointer.X - 25, pointer.Y - 25, 50, 50), PixelFormat.Format32bppRgb);
그리고 마우스 위치에 중점을 둔 100 x 100 픽셀의 직사각형으로 표시하십시오. 그러면 2 배 확대 레벨을 얻을 수 있습니다. (표시 크기)/(캡처 된 크기)의 비율이 클수록 확대 비율이 커집니다.
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
void OnPaint()
{
IntPtr desktopDC = GetDC(IntPtr.Zero); // Get the full screen DC
Graphics g = Graphics.FromHdc(desktopDC); // Get the full screen GFX device
g.DrawImage(portionOf, pointer.X - 50, pointer.Y - 50, 100, 100); // Render the image
// Clean up
g.Dispose();
ReleaseDC(IntPtr.Zero, desktopDC);
}
초기 질문에서 응답을 생성하지 못하면 새 질문을 게시하는 대신 편집해야합니다. –