2012-08-16 3 views
1

나는 C#을 사용하여 부분 확대 도구를 만드는 중입니다. 이 부분과 매우 비슷합니다. http://colorsnapper.com Google의 모든 영역을 검색하여 화면의 미리 정의 된 영역을 확대하여 각 픽셀을 볼 수 있습니다.화면의 특정 영역 확대

더 구체적으로 말하자면, 마우스가 마우스를 가리키면 마우스가 움직이는 각 픽셀을 향상시키는 돋보기가되고 싶습니다. 미리 정의 된 영역을 확대하는 방법을 알아야합니다.

누구나이 작업을 수행 할 수있는 방법이나 사용 가능한 API를 알고 있습니까? http://msdn.microsoft.com/en-us/library/windows/desktop/ms692402(v=vs.85).aspx 그러나,이 API는 C입니다 ++ :

UPDATE는 나는 마이크로 소프트가 제공 한 배율 API를 발견했다. 내가 수집 한 것처럼 C++은 Windows OS가 작성된 것이며이 API를 사용하기 위해 C# 래퍼를 사용해야합니다. 이것은 질문이 아닙니다, 방금 다른 사용자를 위해이 게시물에 추가 할 것이라고 생각했습니다.

당신은 메모리에 비트 맵으로 화면을 캡처 할 수
+1

초기 질문에서 응답을 생성하지 못하면 새 질문을 게시하는 대신 편집해야합니다. –

답변

4

:

/// <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); 
} 
+2

남자에게 물고기를 줘. 잠깐, 아니, OP가 가공 공장을 물려 받았어. – Shibumi