Working with Bitmaps
-
Hello, I'm collecting bitmaps from a camera like below:
private void LPRCamera2_OnNewFrame(object sender, ref Bitmap NewFrame)
{
while (LPR2List.Count >= LowCamSettings.LPR2FrameCount)
{
LPR2List[0].Dispose();
LPR2List.RemoveAt(0);
}if (lpr2FrameIndex >= LowCamSettings.LPR2SkipCount) { LPR2List.Add(new Bitmap(NewFrame)); //List object lpr2FrameIndex = 0; } else if (LowCamSettings.LPR2SkipCount > 0) lpr2FrameIndex++; }
I then take the list (LPR2List) and pass it to a new object that copies the list to a local variable. Like so:
for (int i = 0; i < LPR2List.Count; i++) { if (LPR2List\[i\] != null) this.Plate2List.Add((Bitmap)LPR2List\[i\].Clone()); //Error Line }
Every now and then i'm getting an error when copying telling me that the object is in use. I haven't the slightest clue what I could be doing wrong. Any help would be greatly appreciated.
-
Hello, I'm collecting bitmaps from a camera like below:
private void LPRCamera2_OnNewFrame(object sender, ref Bitmap NewFrame)
{
while (LPR2List.Count >= LowCamSettings.LPR2FrameCount)
{
LPR2List[0].Dispose();
LPR2List.RemoveAt(0);
}if (lpr2FrameIndex >= LowCamSettings.LPR2SkipCount) { LPR2List.Add(new Bitmap(NewFrame)); //List object lpr2FrameIndex = 0; } else if (LowCamSettings.LPR2SkipCount > 0) lpr2FrameIndex++; }
I then take the list (LPR2List) and pass it to a new object that copies the list to a local variable. Like so:
for (int i = 0; i < LPR2List.Count; i++) { if (LPR2List\[i\] != null) this.Plate2List.Add((Bitmap)LPR2List\[i\].Clone()); //Error Line }
Every now and then i'm getting an error when copying telling me that the object is in use. I haven't the slightest clue what I could be doing wrong. Any help would be greatly appreciated.