Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 位图区域块#_C#_Bitmap_Bitmapdata - Fatal编程技术网

C# 位图区域块#

C# 位图区域块#,c#,bitmap,bitmapdata,C#,Bitmap,Bitmapdata,我目前正在写一个程序来过滤图片。 为了使我的程序更快,我将图片分割成多个区域。 为此,我使用LockBits方法阻塞区域 BitmapData data1 = inputimage.LockBits(new Rectangle(0, 0, image.Width, 100), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData data2 = inputimage.L

我目前正在写一个程序来过滤图片。 为了使我的程序更快,我将图片分割成多个区域。 为此,我使用LockBits方法阻塞区域

 BitmapData data1 = inputimage.LockBits(new Rectangle(0, 0, image.Width, 100), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 BitmapData data2 = inputimage.LockBits(new Rectangle(0, 200, image.Width, 100), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
如果我运行这个代码,我会得到一个异常(如果第二个代码行正在执行),我会得到这个区域已经被锁定的异常。 对我来说这毫无意义。这个区域没有被封锁,但我得到的信息是它被封锁了

有人能帮我吗??
Marcel

难道你不能锁定所有内容,然后自己协调访问吗?你要么需要自己管理位图的子区域,要么一次操作一个子区域,在进入下一个子区域之前锁定和解锁。我认为不允许锁定已经锁定的位图。作为Peter Duniho所说的后续内容,没有理由不让多个线程在同一锁定位缓冲区的不同区域上工作。