I have a class "skImage". This class has a private variable (with a public property that exposes it)
private Image _capturedImage;
the constructor of this class looks like:
public skImage(Image captured) {
_capturedImage = captured;
}
It also has the following method:
public bool Invert() {
Bitmap b = new Bitmap(_capturedImage);
unsafe {
//random code not relevant.
}
_capturedImage = b;
b.Dispose();
return true;
}
and then it has a save() method, which just calls:
_capturedImage.Save(_saveFullLocation);
now if i run the invert method and then try calling save it throws an exception (parameter is not valid). After googling this exception it seems like I am disposing of the image. I can see that I am disposing "b" after the invert method.
My question is that when i do _capturedImage = b
does that mean both variables now hold one reference to the object? I dont want that. I want b to be destroyed to relieve memory so the GC can collect it. How do i transfer b to _capturedImage and destroy b.
thanks