If you check my signature, there's a link to the Crop & zoom thread.. It should give you all you the code you'll need to do the crop..

Just you may want too keep track of the Min & max of X and Y, and pass them through to the crop code, so that is an automatic and not manual crop..