做截图时在调用Bitblt时候速度没有加速???

解决方案 »

  1.   

    Bitblt是GDI的函数,是硬件加速的,于用什么语言没啥关系。
      

  2.   

    但是我在Onpaint时调用。。没有一点加速啊
      

  3.   


     Graphics grDest = Graphics.FromHwnd(this.Handle);
     Graphics grSrc = Graphics.FromImage(bmp); 
     
         IntPtr hdcDest = IntPtr.Zero; 
         IntPtr hdcSrc = IntPtr.Zero; 
         IntPtr hBitmap = IntPtr.Zero; 
         IntPtr hOldObject = IntPtr.Zero; 
         try 
         { 
             hdcDest = grDest.GetHdc(); 
             hdcSrc = grSrc.GetHdc(); 
             hBitmap = bmp.GetHbitmap(); 
             hOldObject = SelectObject(hdcSrc, hBitmap); 
             if (hOldObject == IntPtr.Zero)                 
                 throw new Win32Exception(); 
             if (!BitBlt(hdcDest, 0, 0, pictureBox1.Width, pictureBox1.Height, hdcSrc, 0, 0, 0x00CC0020U))                 
                 throw new Win32Exception(); }
         finally 
         { 
             if (hOldObject != IntPtr.Zero) SelectObject(hdcSrc, hOldObject); 
             if (hBitmap != IntPtr.Zero) DeleteObject(hBitmap); 
             if (hdcDest != IntPtr.Zero) grDest.ReleaseHdc(hdcDest); 
             if (hdcSrc != IntPtr.Zero) grSrc.ReleaseHdc(hdcSrc); 
         }