我想通过从服务器(网站)下载图像设置一个旋转的背景图像,并试图用curl做到这一点,但有0成功做到这一点。我的代码(缩写)版本如下。我没有收到错误,但是,如何将此图像“暂时”保存为我的背景?有没有图像(型变量)或什么?从服务器下载图像(cUrl,但采取建议)C++
这只是一个学习的经验,所以任何图书馆或建议将不胜感激。
#include <curl/curl.h>
CURL *curlCtx = curl_easy_init();
curl_easy_setopt(curlCtx, CURLOPT_URL, "http://www.examplesite.com/testimage.jpeg");
curl_easy_setopt(curlCtx, CURLOPT_WRITEDATA, this);
curl_easy_setopt(curlCtx, CURLOPT_WRITEFUNCTION, callbackfunction);
const CURLcode rc = curl_easy_perform(curlCtx);
if(rc == CURLE_OK){
//it worked
}
size_t callbackfunction(char *data, size_t size, size_t nmemb, void *stream){
//do something here with image...?
}
谢谢, 詹姆斯
编辑:对不起,我加()错误地callbackFunction参数。
您在第5行写了'callbackfunction()'而不是'callbackfunction'。 – Blindy 2012-04-11 20:20:07