iPhoneDev
iPhoneDev

Reputation: 3015

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

Upvotes: 1

Views: 1274

Answers (1)

AechoLiu
AechoLiu

Reputation: 18368

I think you can find answer from resize and crop image centered.

Upvotes: 1

Related Questions