I'm working on a piece of code where I want to be able to crop or shift images. During this I have managed to bring down the problem to the following line of code:
Cropped = ScaledImage.Clone(new Rectangle(hscroll, vscroll,ScaledImage.Size.Width, ScaledImage.Size.Height), ScaledImage.PixelFormat);
The actual amount of used memory is not big enough to matter (there is no infinite loop and according to the profiler I have plent of memory left (only some 200mB in use troughout the application out of 4 gigs avaible)).
The line of code here is suposed to either pad in front of an image or crop out the left and top side depending on whatever hscroll and vscroll are positive. ScaledImage is a bitMap that is currently 512 by 512.