如何直接从zip文件中读取图像文件而不提取到磁盘? [英] How do I read image files directly from a zip without extracting to disk?

查看:120
本文介绍了如何直接从zip文件中读取图像文件而不提取到磁盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是在运行时将图像分配给ui元素(想想Winamp风格),但我不知道如何从一个zip而不存储到磁盘读取。或者如何将每个图像分配给一个ui元素

What I want to do is assign images to ui elements at runtime (think Winamp style) but I have no idea how to go about reading from a zip without storing to disk. Or how to assign each image to a ui element

我正在处理一个带有可可和目标c的mac

I'm working on a mac with cocoa and objective c

推荐答案

使用 objective-c zip(iOS / Mac zlib包装器)

然后您可以:

ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:@"test.zip" mode:ZipFileModeUnzip];
[unzipFile goToFirstFileInZip];

ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSMutableData *data= [[NSMutableData alloc] initWithLength:256];
int bytesRead= [read readDataWithBuffer:data];

[read finishedReading];

这篇关于如何直接从zip文件中读取图像文件而不提取到磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆