如何解决Accord位图区域已被锁定异常
大家好,我正在使用Accord视频FFMPEG来捕获视频,但是我却遇到了这种异常,我是否可以知道为什么会发生这种异常以及如何克服这种情况
Bitmap region is already locked.,at System.Drawing.Bitmap.LockBits(Rectangle rect,ImageLockMode flags,PixelFormat format,BitmapData bitmapData)
at System.Drawing.Bitmap.LockBits(Rectangle rect,PixelFormat format)
at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(Bitmap frame,UInt32 frameIndex)
at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(Bitmap frame,TimeSpan timestamp)
at ProHance.PHProbeScreenCapture.VideoCapture.video_NewFrame(Object sender,NewFrameEventArgs eventArgs)
这是我将框架绑定到录像机的代码
Bitmap frame = eventArgs.Frame;
{
Graphics graphics = Graphics.FromImage(frame);
try
{
NativeMethods.CURSORINFO pci;
pci.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(NativeMethods.CURSORINFO));
if (NativeMethods.GetCursorInfo(out pci))
{
if (pci.flags == NativeMethods.CURSOR_SHOWING)
{
int x = pci.ptScreenPos.x - screenLeft;
int y = pci.ptScreenPos.y - screenTop;
Color c = Color.Yellow;
float width = 2;
int radius = 30;
if ((Control.MouseButtons & MouseButtons.Left) != 0 || (Control.MouseButtons & MouseButtons.Right) != 0)
{
c = Color.OrangeRed;
width = 4;
radius = 35;
}
Pen p = new Pen(c,width);
graphics.DrawEllipse(p,x - radius / 2,y - radius / 2,radius,radius);
NativeMethods.DrawIcon(graphics.GetHdc(),x,y,pci.hCursor);
graphics.ReleaseHdc();
}
}
this._writer.WriteVideoFrame(frame,(DateTime.Now - videoStartTime));
}
catch (Exception)
{
this._writer.WriteVideoFrame(eventArgs.Frame,(DateTime.Now - videoStartTime));
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。