logo

English

이곳의 프로그래밍관련 정보와 소스는 마음대로 활용하셔도 좋습니다. 다만 쓰시기 전에 통보 정도는 해주시는 것이 예의 일것 같습니다. 질문이나 오류 수정은 siseong@gmail.com 으로 주세요. 감사합니다.

digipine2017.11.02 21:01
[[DllImport("gdi32.dll")]
static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int
wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, CopyPixelOperation rop);
[DllImport("user32.dll")]
static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDc);
[DllImport("gdi32.dll")]
static extern IntPtr DeleteDC(IntPtr hDc);
[DllImport("gdi32.dll")]
static extern IntPtr DeleteObject(IntPtr hDc);
[DllImport("gdi32.dll")]
static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
[DllImport("gdi32.dll")]
static extern IntPtr CreateCompatibleDC(IntPtr hdc);
[DllImport("gdi32.dll")]
static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr ptr);
 
 
private Bitmap CaptureScreen(int x, int y, int 넓이, int 높이)
{
IntPtr hDC = GetDC(IntPtr.Zero);
IntPtr hMemDC = CreateCompatibleDC(hDC);
IntPtr hBitmap = CreateCompatibleBitmap(hDC, 넓이, 높이);
 
IntPtr hOld = (IntPtr)SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, -x, -y, 넓이+x, 높이+y, hDC, 0, 0, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt);
SelectObject(hMemDC, hOld);
 
DeleteDC(hMemDC);
ReleaseDC(IntPtr.Zero, hDC);
 
Bitmap memoryImage = System.Drawing.Image.FromHbitmap(hBitmap);
DeleteObject(hBitmap);
 
return memoryImage;
}
 
Attach

Drag and drop your files here, or Click attach files button.

Maximum File Size : 0MB (Allowed extentsions : *.*)

0 file(s) attached ( / )