我正在尝试将来自 Linux (c++ / Qt4.5.x) 服务器守护程序的 png 图像提供给使用 Three20 框架的 iPhone 应用程序 - 特别是我想使用 TTThumbsViewController 视图。
当它“GET”sa请求时,我设法使任何Web浏览器查看图像,并在我的守护程序中返回以下内容:
QTextStream os(socket);
os.setAutoDetectUnicode(true);
QByteArray base64 = array.toBase64();
os << "HTTP/1.1 200 Ok\r\n"
"Host: software.local\r\n"
"\r\n"
"<html>"
"<body>"
"<img src=\"data:image/png;base64," << base64 << "\" />"
"</body>";
其中“array”是 png 的图像数据;我正在输入类似的内容:
http://software.local:8080/test.png
在浏览器中查看图像。
当我尝试在我的照片源类中指定相同的 URL 时
[MockPhoto alloc]
initWithURL:@"http://software.local:8080/test.png"
smallURL:@"http://software.local:8080/test.png"
size:CGSizeMake(480, 320)] autorelease],
...
什么都没有返回或显示?
我的问题是真的 - 如果我将 test.png 放在 Linux PC 上的合适目录中并启动 Web 服务器(apache),然后浏览到“ http://software.local/test.png我看到如上图,但图像没有嵌入到 http 标头中?我真的不知道标头应该是什么才能获得这种行为。如果我在上面的 iPhone 代码中设置 URL,以便它从我看到的 apache 服务器加载 png它在 TTThumbsViewController 中。
任何帮助都会很好,或者更好的方法来做到这一点 - 正如你所看到的,我只有基本的 http 经验。