- UIGraphicsBeginImageContext(cropRect.size);
-
- [originalImage drawAtPoint:CGPointMake(-CGRectGetMinX(cropRect),
- -CGRectGetMinY(cropRect))];
-
- imageToDecode = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
+ if (([picker sourceType] == UIImagePickerControllerSourceTypeSavedPhotosAlbum) &&
+ [@"2.1" isEqualToString:systemVersion]) {
+ // adjust crop rect to work around bug in iPhone OS 2.1 when selecting from the photo roll
+ cropRect.origin.x *= 2.5;
+ cropRect.origin.y *= 2.5;
+ cropRect.size.width *= 2.5;
+ cropRect.size.height *= 2.5;
+#ifdef DEBUG
+ NSLog(@"2.1-adjusted crop rect = (%f, %f) x (%f, %f)", CGRectGetMinX(cropRect), CGRectGetMinY(cropRect), CGRectGetWidth(cropRect), CGRectGetHeight(cropRect));
+#endif
+ }
+
+ imageToDecode = originalImage;