I have planed to create a image edit application. first step i gonna show touched position of image in to a separate image view from original image view.
Its's working fine when test with default image(which one is set from xcode storyboard attribute inspector).
But its not crop a exact image when i import a photo from device "Photos".
I am really confused and stuck on there. please some one guide me to do this task.
I have try with the Below code
Thanks in advance.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info valueForKey:UIImagePickerControllerEditedImage];
imgVw.image = image;
// croperImgvw.image = [self cropImage : image];
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (UIImage *)cropImage:(UIImage *)image : (CGPoint)point
{
CGRect clippedRect =CGRectMake(point.x, point.y, 50, 50);
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], clippedRect);
UIImage * croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return croppedImage;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touch_point = [touch locationInView:self.view];
NSLog(@"X location: %f", touch_point.x);
NSLog(@"Y Location: %f",touch_point.y);
CGPoint point = [touch locationInView:self.view];
croperImgvw.image = [self cropImage:[imgVw image] :point];
}