求高效截屏和分块代码
目前用的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);
[其他解释]
友情关注,解决了望楼主分享
[其他解释]
该回复于2010-12-24 16:02:05被版主删除
[其他解释]
myDevice.GetFrontBufferData(0, mySurface); //copy frontsurface to mySurface
Microsoft.DirectX.GraphicsStream gStr = Microsoft.DirectX.Direct3D.SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, mySurface);
// pictureBox1.Image = Bitmap.FromStream(gStr);
Bitmap screen = new Bitmap(Bitmap.FromStream(gStr));
gStr.Dispose();
mySurface.Dispose();
}
catch (Exception ee)
{
Tools.Trace(ee.ToString());
mySurface.Dispose();
}
string datetime2 = DateTime.Now.ToString("HH:mm:ss:ff");
}
使用的DX,速度也差不多 = =。请问是哪的使用问题吗
[其他解释]
该回复于2010-12-27 09:24:14被版主删除
[其他解释]