Created
May 25, 2010 15:30
-
-
Save soundkitchen/413266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "testApp.h" | |
void testApp::setup() | |
{ | |
ofAddListener(httpUtils.newResponseEvent, this, &testApp::newResponse); | |
httpUtils.start(); | |
ofxHttpForm form; | |
form.action = "http://example.com/images/hoge.jpg"; | |
form.method = OFX_HTTP_GET; | |
httpUtils.addForm(form); | |
} | |
void testApp::newResponse(ofxHttpResponse &response) | |
{ | |
FIMEMORY *hmem = NULL; | |
FIBITMAP *bmp = NULL; | |
hmem = FreeImage_OpemMemory((unsigned char *)response.responseBody.c_str(), | |
response.responseBody.size()); | |
if (hmem == NULL) { | |
ofLog(OF_LOG_ERROR, "hmem is NULL."); | |
return; | |
} | |
FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem); | |
bmp = FreeImage_LoadFromMemory(fif, hmem, 0); | |
if (bmp == NULL) { | |
ofLog(OF_LOG_ERROR, "bmp is NULL."); | |
return; | |
} | |
FreeImage_Save(fif, bmp, ofToDataPath("thumb.jpg").c_str(), 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
#include "ofxHttpUtils.h" | |
class testApp:public ofBaseApp | |
{ | |
// (snip) | |
private: | |
ofxHttpUtils httpUtils; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment