curl-users
curl png image from string stream/buff to image format
Date: Thu, 26 May 2011 16:33:56 -0500
Curl users
I am sure this topic has been asked before, but still 'cannot find a good answer after googleing and
searching the archives.
Hope someone can answer asap.
My situation: Working on windows vista version
I have a downloaded a png image into buffer through the following
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &imgbuf);
curl_easy_setopt(curl, CURLOPT_URL,"http://.../imge.png");
result = curl_easy_perform(curl);
//where imgbuf is string type
if(result == CURLE_OK){
here after filling buffer from download, what is the best and easy way to
get into image format, preferably png or bmp
gdiplus (gdiplus+) preferred or any windows imaging lib/dll
need a sort of skeleton code. Thanks a bunch for answering.
with best regards
here is what 'came up with for GDIPlus
if you wanted to see (but doesnt work)
====================
istringstream ss1(imgbuf); //tried stringstream and other combinations too
HGLOBAL hBuffer;
hBuffer = ::GlobalAlloc(GMEM_MOVEABLE,sizeof(ss1));
void* pBuffer = ::GlobalLock(hBuffer);
CopyMemory(pBuffer, ss1, sizeof(ss1)); //is this the right way?
IStream* pStream = NULL;
if(::CreateStreamOnHGlobal(hBuffer,FALSE,&pStream) == S_OK)
{
Image * m_BackImage = Gdiplus::Image::FromStream(pStream,false);
PixelFormat pf = m_BackImage->GetPixelFormat();
cout<< "the image format " <<
m_BackImage->GetPixelFormat() << " pf is " << pf <<
"the const is " << PixelFormat24bppRGB
<< endl;
if(pf == PixelFormat24bppRGB)
printf("The pixel format of image 1 is 24bppRGB.\n");
==========================
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-27