保存 UIImage 的最快方法
我这里有一个小问题;我的目标是能够以非常快的速度处理图像,也许每秒最多 10 张图像。 发生的事情是我得到一个 CGImage,将其转换为 UIImage,并将其保存到磁盘。但我意识到使用 writeToFile 保存相当“慢”,因为我需要能够每秒保存十个。 所以我想知道,有没有更快的方法来保存图像? 或者我应该将每个图像添加到一个数组中,并让辅助线程以自己的速度处理它们?
非常感谢!
I have a little issue here; my goal is to be able to process images at a very fast rate, maybe up to 10 images per second.
What is happening is I'm getting a CGImage, converting it to UIImage, and saving it to disk. But I'm realizing that saving using writeToFile is quite "slow", as I need to be able to save ten of these per second.
So I was wondering, is there a faster way to save an image?
Or should I add each image to an array, and have a secondary thread process them at it's own speed?
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以将数据缓存到内存中的数组中,然后再将其写出。
但是,您需要以比写入后备存储的速度更快的速度保存多少图像?在某些时候,您将填满可用内存,并且必须停止、减少记录或丢弃数据。
Yes, you can cache data to an array in memory and write it out later.
But how many images do you need to save at a rate faster than you can write to backing store? At some point you will fill up available memory, and have to stop, record less, or discard data.