It was giving me problems (image ended up in the wrong location)when I move the image around i.e. translation. My image size was different from the view size and in my case that's the screen size (320X480) I noticed that if my image were exactly the same size as the view size then the existing code works perfectly otherwise there's the problem I described. Also I wasn't sure why it was doing a draw twice so I cut that out. Here are the results of my changes:
-(UIImage*) getCroppedImageFromView

UIView *)view image

UIImage *)image {
// Begin the drawing
CGRect rect = view.bounds;
UIGraphicsBeginImageContext(CGSizeMake(rect.size.w idth,rect.size.height));
CGContextRef ctx = UIGraphicsGetCurrentContext();
// Clear whole thing
CGContextClearRect(ctx, rect);
// Transform the image (as the image view has been transformed)
CGContextTranslateCTM(ctx, rect.size.width*0.5, rect.size.height*0.5);
CGContextConcatCTM(ctx, view.transform);
CGContextTranslateCTM(ctx, -rect.size.width*0.5, -rect.size.height*0.5);
// Tanslate and scale upside-down to compensate for Quartz's inverted coordinate system
CGContextTranslateCTM(ctx, 0.0, rect.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
// Draw view into context
CGContextDrawImage(ctx, rect, image.CGImage);
// Create the new UIImage from the context
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
// End the drawing
UIGraphicsEndImageContext();
return newImage;
}
Again thanks for sharing.