Get average color of UIImage in Swift

前端 未结 5 2324

I was recently attempting to convert the code from here into Swift. However, I keep getting a white color, no matter the image. Here\'s my code:

// Playgroun         


        
5条回答
  •  太阳男子
    2020-12-14 23:48

    CoreImage in iOS 9: use the CIAreaAverage filter and pass the extent of your entire image to be averaged.

    Plus, it's much faster since it'll either be running on the GPU or as a highly-optimized CPU CIKernel.

提交回复
热议问题