日期:2014-05-17  浏览次数:21028 次

求高效截屏和分块代码
目前用的DC,BitBlt 方法 截一屏将近160MS 分块也差不多160MS(4*4)

分块代码:

                       graphic.DrawImage(im, 0, 0, new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
                        //从作图区生成新图
                        IntPtr pr = bitmap.GetHbitmap();
                        Image MyImage = Image.FromHbitmap(pr);
                        DeleteObject(pr);
                        //
                        byte[] tmpbyte = CompressByte(imageToByteArray(MyImage));//转换为字节压缩。
在另外一台17寸电脑上操作更是消耗 860MS。

求高效方法,DirecxX ,差异截图 等方法
------最佳解决方案--------------------

 Image deskImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format24bppRgb);
                Graphics deskG = Graphics.FromImage(deskImage);
                deskG.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.PrimaryScreen.Bounds.Size);

                Rectangle targRect = new Rectangle(0, 0,640, 480);
                Image baseImage = new Bitmap(640, 480, PixelFormat.Format24bppRgb);
                Graphics baseG = Graphics.FromImage(baseImage);
                baseG.DrawImage(deskImage, targRect, new Rectangle(0, 0, deskImage.Width, deskImage.Height), GraphicsUnit.Pixel);


------其他解决方案--------------------
graphic.DrawImage(im, 0, 0, new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
  //从作图区生成新图
  IntPtr pr = bitmap.GetHbitmap();
  Image MyImage = Image.FromHbitmap(pr);
  DeleteObject(pr);

-------------------
graphic.DrawImage(im, 0, 0, new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
Image MyImage =bitmap;
bitmap.dispose; '释放

截屏可用:
graphic.CopyFromScreen(..)

------其他解决方案--------------------
http://topic.csdn.net/u/20090911/14/5614a16e-ab08-4106-901e-e8dcc5cd1fa3.html?44754
------其他解决方案--------------------
http://topic.csdn.net/u/20090911/14/5614a16e-a