为什么某些图像会使用gpuimage过滤旋转90度?

时间:2018-11-26 10:24:13

标签: ios gpuimage

  

问题:为什么某些图像会使用gpuimage过滤旋转90度?

var sourcePicture:GPUImagePicture?
func setupFilters(image:UIImage,gpuImageView:GPUImageView){
    let filers = [brightnessFilter,
                  exposureFilter,
                  contrastFilter,
                  saturationFilter,
                  whiteBalanceFilter,
                  hightlightShadowFilter,
                  rgbFilter]
    sourcePicture = GPUImagePicture(image: image, smoothlyScaleOutput: true)
    pipeline = GPUImageFilterPipeline(orderedFilters: filers, input: sourcePicture, output: gpuImageView)

    weak var weakSource = sourcePicture
    DispatchQueue.main.async(execute: {
        weakSource?.processImage()
    })
}

1 个答案:

答案 0 :(得分:0)

我使用了一些不同的方法,但是在使用GPUImagePicture之后,您应该显式设置图像方向。恰好在processImage()之后,例如:

    func lutFilter(image: UIImage) -> UIImage {
    var imageCopy = image
    let picture = GPUImagePicture(image: image)
    let lut = GPUImagePicture(image: UIImage(named: "lookup_amatorka"))
    let filter = GPUImageLookupFilter()
    lut?.addTarget(filter, atTextureLocation: 1)
    picture?.addTarget(filter, atTextureLocation: 0)

    filter.useNextFrameForImageCapture()

    lut?.processImage()
    picture?.processImage()

    imageCopy = filter.imageFromCurrentFramebuffer(with:   image.imageOrientation)

    return imageCopy
}