iPad如何将多个UIImage保存到一个文件

发布于 2024-09-04 11:22:25 字数 229 浏览 3 评论 0原文

我有一个可以显示文档页面的 PDF 阅读器。我想要做的是允许用户在透明视图中绘制 PDF。然后我想将绘图(UIImage)保存到磁盘。如果可能的话,我不想让文档文件夹充满像 documentName_page01.png、documentName_page02.png 这样绘制的每个页面的文件。

但是,我不知道如何将这些 UIImage 存储到单个文件中,而不会使它变得笨重且占用大量内存。

任何想法表示赞赏。

I have a PDF reader that displays pages of the document. What I want to do is allow the user to draw over the PDF in a transparent view. Then I want to save the drawing (UIImage) to disk. If at all possible, I don't want to have the documents folder filled with files like documentName_page01.png, documentName_page02.png for every page that is drawn over.

However, I can't figure out how to store these UIImages into a single file without it becoming unwieldy and memory intensive.

Any ideas appreciated.

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

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

发布评论

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

评论(2

风和你 2024-09-11 11:22:25

用户画的是什么,只是直线、矩形、圆形等?也许存储需要绘制的颜色和路径,将所有这些放入 NSArray 中并序列化。这可能比尝试将多个 UIImage 放入一个文件更容易,占用的设备空间更少,并且加载速度可能更快。然后重新创建图纸。

What is the user drawing, just lines, rectangles, circles and so on? Maybe store colors and paths of what needs to be drawn, put all of that into an NSArray and serialise that. That might be easier than trying to put multiple UIImages into a file, will use up less space on the device, and might be faster to load. Then just recreate the drawings.

烟若柳尘 2024-09-11 11:22:25

使用 Core Data 将图像存储在二进制数据字段中并从那里检索它们。这样,无论您有多少个 PDF、多少页,您都不会用图像填充您的文档文件夹。 这里的教程向您展示了如何执行此操作。

Use Core Data to store your images in Binary Data fields and retrieve them from there. This way, you won't fill your Documents folder with images, no matter how many PDFs of how many pages you have. Here's a tutorial showing you how to do this.

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