Search code examples
iphoneimage-processingcore-graphicsuigesturerecognizeruitouch

draw rect on image which can be resized & moved on screen using touch


i am creating a application which provides custom image cropping…. in which user select one portion of image using rectangle which should be re-sized & can be moved as per user-touch to crop that portion……

i want rect on image so that i can crop that portion using following method

i am able to crop rect on image by following method

-(void) cropImage
{
   CGSize size = iv.frame.size;

   CGRect rect = CGRectMake(size.width / 4, size.height / 4, size.width/2,size.height / 2);

   CGImageRef imageRef = CGImageCreateWithImageInRect([iv.image CGImage], rect);    
   UIImage *img = [UIImage imageWithCGImage:imageRef]; 

   CGImageRelease(imageRef);        

   // Display Image     
   UIImageView *imageView = [[UIImageView alloc] initWithImage:img];    
   [imageView setFrame:CGRectMake(70.0, 480.0,(size.width / 2), (size.height / 2))];    
   [scrollView addSubview:imageView]; 

   [imageView release];

   [scrollView scrollRectToVisible:imageView.frame animated:YES];

}

i want solution for drawing rect that can be resized by touch & moved by touch...

i am new to iPhone so....pls help me how to do that....


Solution

  • i got my answer from nice example form this link Image Cropper..

    if anyone have better than this please pot it here....if it deserve that i will accept that answer