Answer the question
In order to leave comments, you need to log in
How to get rid of the "Bitmap area is already locked" error?
Hello!
I work with the Bitmap class.
on the line
Bitmap ImageBitmap = new Bitmap(img);
The program throws an error:
An unhandled exception of type 'System.InvalidOperationException' in System.Drawing.dll
Additional information: The bitmap region is already locked.
A possible reason is that I work simultaneously with two Bitmaps?
using (var wr = new ImageWrapper((Bitmap)img))
{
//бинаризация
foreach(var p in wr)
wr[p]=wr[p].GetBrightness()>treshold_Otsu(img) ? Color.White : Color.Black;
}
return img;
Answer the question
In order to leave comments, you need to log in
The error is completely idiotic, it is enough to assign the value of treshold_Otsu to some variable.
I'm sorry for the inconvenience.
Time is running out so nerves are on edge)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question