It is fair to point out that "Out of memory" is also the error you get if you try to open a graphic that is not ready to be opened, usually because it is opened in another program... maybe still being written etc.
Also the line you are using:
- Bitmap picBitmap = new Bitmap(@"Location");
while simple, sucks. It holds the file open on the hard drive until you are done with the bitmap object and your program disposes of it.
Make sure you copy the bitmap to a new bitmap object as soon as you can and dispose of the 'link' to the file. Otherwise your program is keeping the file open and even you won't be able to read it in a second time if you tried to for some reason.
- Bitmap tempBitmap = new Bitmap(@"Location");
-
Bitmap myBitmap = (Bitmap)tempBitmap.Clone();
Or something similar has treated me well in the past.
Of course this means that for a moment you will have 2 x 500meg objects in memory. So you need a lot of RAM for this project.