小编Jam*_*mes的帖子

从服务器下载图像(cUrl,但是提出建​​议)C++

我试图通过从服务器(网站)下载图像设置旋转背景图片,并试图与这样卷曲然而有0成功做到这一点.我的代码的(缩短版)如下所示.我没有收到错误,但是,如何"临时"保存此图像以将其显示为我的背景?有图像(-type变量)还是什么?

这只是一次学习经历,因此非常感谢任何图书馆或建议.

#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...?
}
Run Code Online (Sandbox Code Playgroud)

谢谢,詹姆斯

编辑:对不起我错误地添加了()回调函数.

c c++ curl image download

2
推荐指数
1
解决办法
4322
查看次数

标签 统计

c ×1

c++ ×1

curl ×1

download ×1

image ×1