请问:
怎么把一个FORM里面的内容,都保存到一个BMP图片文件中去?
谢谢!

解决方案 »

  1.   

    参考这里:
    http://s5689412.cnblogs.com/archive/2005/10/26/262258.html
      

  2.   

    IntPtr dc = GetDC(IntPtr.Zero);
    Graphics dcG = Graphics.FromHwnd(IntPtr.Zero);
    Bitmap bmp = new Bitmap(Width,Height,dcG);
    Graphics bmpG = Graphics.FromImage(bmp);
    IntPtr hdcDest = bmpG.GetHdc();
    BitBlt(hdcDest,0,0,bmp.Width,bmp.Height,dc,Left,Top,0x00CC0020);
    bmpG.ReleaseHdc(hdcDest);
    bmpG.Dispose();
    bmp.Save(@"c:\zlc.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
    bmp.Dispose();
    dcG.Dispose();
    ReleaseDC(IntPtr.Zero,dc);
      

  3.   

    api声明
    [DllImport("user32.dll", CharSet=CharSet.Auto)]
    static public extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll", CharSet=CharSet.Auto)]
    static public extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

    [DllImport("gdi32.dll", CharSet=CharSet.Auto)]
    static public extern bool BitBlt(IntPtr hdcDest, // handle to destination device context 
    int nXDest, // x-coordinate of destination rectangle's upper-left corner
    int nYDest, // y-coordinate of destination rectangle's upper-left corner
    int nWidth, // width of destination rectangle 
    int nHeight, // height of destination rectangle 
    IntPtr hdcSrc, // handle to source device context 
    int nXSrc, // x-coordinate of source rectangle's upper-left corner  
    int nYSrc, // y-coordinate of source rectangle's upper-left corner
    uint dwRop); // raster operation code );