Re-Size image in UIImagePicker im iPhone
I am using UIImagePicker to capture image from camera. My problem is I want to re-size the开发者_如何学运维 image with custom coordinate.
So let I have frame in which user can take a picture and I want to save ONLY that frame area. Ex: if I am taking picture of a person the frame is covering his face then I just need to save the face area not the background the other body portion.
The code which I am using is : `
CGRect scaledRect = CGRectZero;
CGSize targetSize = CGSizeMake( baseImage.size.width,baseImage.size.height);
scaledRect.origin = CGPointMake(0, 0);
scaledRect.size.width = baseImage.size.width;
scaledRect.size.height = baseImage.size.height;
UIGraphicsBeginImageContext(targetSize);
[baseImage drawInRect:scaledRect];
UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
`
One more question, Do I need to worry about device orientation too? If user is taking picture in landscape mode do I need to handle this?
Please suggest
I think you can find answer from resize and crop image centered.
精彩评论