iPhone:模糊 UIImage
在我的 iPhone 应用程序中,我有一个黑白 UIImage
。我需要模糊该图像(高斯模糊即可)。
iPhone 显然知道如何模糊图像,正如 它所做的那样当它绘制阴影时。
但是我在API中没有找到任何相关的内容。
我是否必须在没有硬件加速的情况下手动进行模糊?
In my iPhone application I have a black-and-white UIImage
. I need to blur that image (Gaussian blur would do).
iPhone clearly knows how to blur images, as it does that when it draws shadows.
However I did not found anything related in the API.
Do I have to do blurring by hand, without hardware acceleration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
试试这个(在此处找到):
这样使用它:
并像 只需应用此效果两次或更多次即可获得更强的模糊效果:)
Try this (found here):
And use it like this:
To get stronger blur just apply this effect twice or more :)
过去遇到同样的问题后,检查这个库:
https://github.com/tomsoft1/StackBluriOS
也非常容易使用:
After having the same problem by the past, check this lib:
https://github.com/tomsoft1/StackBluriOS
Very easy to use also:
考虑通过 CIFilter 来完成这项工作:
为 iOS 开发核心图像过滤器
Consider approaching the job via CIFilter:
Developing Core Image Filters for iOS
基本上没有直接的 API 来实现模糊效果。您需要处理像素才能实现这一点。
iPhone 通过渐变而不是模糊来绘制阴影。
Basically there is no a straight forward API to implement the blur effect. You need to process the pixels to accomplish that.
iPhone draw shadows by means of gradient and not through blurring.
要模糊图像,您可以使用卷积矩阵。这是应用卷积矩阵的示例代码,这是卷积矩阵概述以及一些示例矩阵(包括模糊和高斯模糊)。
To blur an image, you would use a convolution matrix. Here is the sample code to apply a convolution matrix, and here is an overview of convolution matrices as well as some sample matrices (including blur and gaussian blur).