How to crop Image using rectangle?

I am trying to crop an image using this rectangle.But Not getting how to stretch the rectangle.I am having one UIView that is outside and within that other view shown with black border. When I stretch DO i need to change the frame for both UIViews ??

should use Pinchgesture to stretch the rectangle or any other method??

Here four blue handlers are UIView s. How will i determine the dragging of them?? If there please suggest.

Answers


Following code for the selecting the box and cropping the image.

-(IBAction) cropImage:(id) sender{
    // Create rectangle that represents a cropped image  
    // from the middle of the existing image
float xCo,yCo;
float width=bottomCornerPoint.x-topCornerPoint.x;
float height=bottomCornerPoint.y-topCornerPoint.y;
if(width<0)
width=-width;
if(height<0)
    height=-height;
         if(topCornerPoint.x <bottomCornerPoint.x)
         {
               xCo=topCornerPoint.x;
          }
         else 
         {
             xCo=bottomCornerPoint.x;
         } 
        if(topCornerPoint.y <bottomCornerPoint.y)
        {
             yCo=topCornerPoint.y;
         }
      else {
             yCo=bottomCornerPoint.y;
       }
    CGRect rect = CGRectMake(xCo,yCo,width,height);
    // Create bitmap image from original image data,
    // using rectangle to specify desired crop area
    UIImage *image = [UIImage imageNamed:@"abc.png"];
    CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], rect);
    UIImage *img = [UIImage imageWithCGImage:imageRef]; 
    CGImageRelease(imageRef);
    // Create and show the new image from bitmap data
    imageView = [[UIImageView alloc] initWithImage:img];
    [imageView setFrame:CGRectMake(110, 600, width, height)];
    imageView.image=img;
    [[self view] addSubview:imageView];
    [imageView release];
}

Hope this may helping to lot


Need Your Help

Having some trouble with a static array

java arrays string methods static

I've been trying to make a game for fun/practice, and I tried to use a method to make the program shorter. Here's the method, and the relevant variables:

Get output of Netcat in Pythonscript

python shell netcat

I need to get the output from netcat in python script.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.