How to crop the image in iPhone

前端 未结 2 801
既然无缘
既然无缘 2021-01-13 20:55

I want to do the same thing as asked in this question. In my App i want to crop the image like we do image cropping in FaceBook can any one guide me with the link of good tu

2条回答
  •  半阙折子戏
    2021-01-13 21:31

    CGRect rectImage = CGRectMake(p1.x,p1.y, p2.x - p1.x, p4.y - p1.y);

    //Create bitmap image from original image data,
    //using rectangle to specify desired crop area
    
    CGImageRef imageRef = CGImageCreateWithImageInRect([imageForCropping CGImage], rectImage); 
    UIImage *croppedImage = [UIImage imageWithCGImage:imageRef]; 
    imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(p1.x, p1.y,p2.x-p1.x p4.y-p1.y)];
    imageView1.image = croppedImage;
    [self.view addSubview:imageView1];
    CGImageRelease(imageRef);
    

提交回复
热议问题