【发布时间】:2012-08-10 16:24:35
【问题描述】:
我在 iOS 中使用 BJImageCropper 进行图像裁剪,但是当我触摸图像的最后一个角时,它会自动更新另一侧的高度和宽度。
示例代码为https://github.com/barrettj/BJImageCropper/zipball/master
【问题讨论】:
标签: iphone ios objective-c ios5 crop
我在 iOS 中使用 BJImageCropper 进行图像裁剪,但是当我触摸图像的最后一个角时,它会自动更新另一侧的高度和宽度。
示例代码为https://github.com/barrettj/BJImageCropper/zipball/master
【问题讨论】:
标签: iphone ios objective-c ios5 crop
获取我刚刚推送的提交。应该固定在那里。
【讨论】:
这是代码中的错误。联系作者纠正错误:)
【讨论】:
您可以使用另一个选项来裁剪图像,即 ContextRect
一个简短的例子是:
CGRect contextRect = CGRectMake(50, 50, 200, 200);
UIGraphicsBeginImageContext(contextRect.size);
[self.view.layer renderInContext : UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], contextRect);
UIImage * savedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:viewImage.imageOrientation];
您可以根据您的图像编辑视图的 x,y 原点和宽度 n 高度。
【讨论】: