【问题标题】:image crop in ios using BJImageCropper使用 BJImageCropper 在 ios 中裁剪图像
【发布时间】:2012-08-10 16:24:35
【问题描述】:

我在 iOS 中使用 BJImageCropper 进行图像裁剪,但是当我触摸图像的最后一个角时,它会自动更新另一侧的高度和宽度。

示例代码为https://github.com/barrettj/BJImageCropper/zipball/master

【问题讨论】:

    标签: iphone ios objective-c ios5 crop


    【解决方案1】:

    获取我刚刚推送的提交。应该固定在那里。

    【讨论】:

    • 嗨 BarrettJ,如果我想以 1:1 的比例添加裁剪。像方形图像裁剪那么怎么做呢?
    • @BarrettJ 裁剪图像太宽且高度太低时已经存在问题。图像增加了额外的宽度和高度。那里显示额外的黑色图像。
    • 使用 PEPhotoCropEditor (github.com/kishikawakatsumi/PEPhotoCropEditor)。比 BJImageCropper 好。
    【解决方案2】:

    这是代码中的错误。联系作者纠正错误:)

    【讨论】:

      【解决方案3】:

      您可以使用另一个选项来裁剪图像,即 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 高度。

      【讨论】:

        猜你喜欢
        • 2013-05-25
        • 2012-03-20
        • 2016-06-16
        • 2011-10-28
        • 2014-01-31
        • 2012-04-22
        • 1970-01-01
        • 2015-02-02
        相关资源
        最近更新 更多