Code Snippet
[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd);
[DllImport("User32.dll")]
public extern static int ReleaseDC(System.IntPtr hWnd, System.IntPtr
void SaveImage()
{
System.IntPtr srcDC=GetDC(this.pictureBox1.Handle);
Bitmap bm=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
Graphics g=Graphics.FromImage(bm);
System.IntPtr bmDC=g.GetHdc();
BitBlt(bmDC,0,0,bm.Width,bm.Height,srcDC,0,0,0x00CC0020 /*SRCCOPY*/);
ReleaseDC(this.pictureBox1.Handle, srcDC);
g.ReleaseHdc(bmDC);
g.Dispose();
}