滚动时读取 UIImage 数据,优缺点

发布于 2024-12-22 17:15:33 字数 441 浏览 2 评论 0原文


我正在使用 NSFileManager 对我保存在设备上的一些图像进行某种滚动,

每次用户滚动到特定单元格时,我都会读取图像数据并加载它,并且滚动是有点慢而且不稳定,

目前要从磁盘读取图像,我使用 [NSFileManagercontentsAtPath: myFile] 然后使用 [UIImage imageWithData: imageData]

我想知道是否有更简单、更有效的方法来做到这一点, 我想过将图像预加载到内存中,但这些图像每个都是 700x700 像素,我担心这会导致内存使用过多,

无论如何,我还在其他一些线程上看到 JPG 表示似乎占用了更多内存比 PNG ,所以将所有内容更改为 PNG 后,它似乎工作得更好一些,但仍然不够快。

很想听听您的经历:)
Shai。

I'm doing some sort of scroller for some images i've saved on the device using NSFileManager,

Everytime the user scrolls into the specific cell i read the image data and load it, and the scrolling is a bit slow and choppy,

Currently to read an image from the disk i use [NSFileManager contentsAtPath: myFile] and then [UIImage imageWithData: imageData] .

I wanted to know if theres an easier and more efficient way to do this ,
I thought of just preloading the images into memory, but these images are 700x700 pixels each and i'm afraid it would cause over-memory usage,

Anyways, i also saw on some other thread that JPG Representations seem to take up a lot more memory than PNG, so after changing everything to PNG , it seemed to be working a bit better, but still not fast enough.

Would love to hear from your experiences :)
Shai.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲喜皆因你 2024-12-29 17:15:33

Apple 有一个延迟图像加载示例,可以获取您开始从本地或网络位置加载图像。

Apple has a lazy image loading example that can get you started loading images from local or network locations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文