【问题标题】:Filter not apply properly in GPUImageBulgeDistortionFilter过滤器在 GPUImageBulgeDistortionFilter 中未正确应用
【发布时间】:2018-07-18 19:03:08
【问题描述】:

我想让点击的图像区域缩放。

当我将 GPUImageBulgeDistortionFilter 应用于图像时,它在中心点 (0.5 , 0.5) 处正常工作,但是当中心点发生变化时,图像上的效果不会作为给定的中心点应用。

Image Square工作正常。

图像宽度 > 图像高度。中心点 (0.5, 0.2) 适用于 (0.5, 0.1) 中心点 (0.5, 0.8) 适用于 (0.5, 0.9)

图像宽度 。中心点 (0.5, 0.2) 应用于 (0.5, 0.3),中心点 (0.5, 0.8) 应用于 (0.5, 0.7)

func tapGesture(_ sender: Any){
    let points = tap.location(ofTouch: 0, in: ivPic)
    let stillImageFilter = GPUImageBulgeDistortionFilter()
    stillImageFilter.center = CGPoint(x: points.x / ivPic.frame.size.width, y: points.y / ivPic.frame.size.height)
    stillImageFilter.radius = 0.1
    stillImageFilter.scale = 0.1
    ivPic.image = stillImageFilter.image(byFilteringImage: ivPic.image)
}

【问题讨论】:

    标签: ios swift image-processing uiimage gpuimage


    【解决方案1】:

    试试这个

    func tapGesture(_ sender: Any) {
    
        let points = tap.location(in: ivPic)
        let stillImageFilter = GPUImageBulgeDistortionFilter()
        let aspectRatio = ivPic.frame.size.height / ivPic.frame.size.width
        stillImageFilter.center = CGPoint(x: points.x / ivPic.frame.size.width, y: ((((points.y / ivPic.frame.size.height) * aspectRatio) + 0.5) - (0.5 * aspectRatio)))
    
        stillImageFilter.radius = 0.1
        stillImageFilter.scale = 0.1
    
        ivPic.image = stillImageFilter.image(byFilteringImage: ivPic.image)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 2018-07-08
      • 1970-01-01
      • 2012-06-12
      • 2018-11-18
      相关资源
      最近更新 更多