[SDL] Search function to display picture got with libcurl
Damien Fawks
damien_fawks at hotmail.com
Sun Jun 24 07:19:43 PDT 2007
Hi there,
I'm writing a piece of software to display a picture located on a server in an SDL window. I'm getting the picture with libcurl using this code :
handle=curl_easy_init();
curl_easy_setopt(handle,CURLOPT_URL,"http://192.168.0.20/image.jpg");
curl_easy_setopt(handle,CURLOPT_WRITEFUNCTION,update_img);
curl_easy_perform(handle);
curl_easy_cleanup(handle);
For performance reasons, I cannot make a disk access to store the picture and recall it with with IMG_Load. So I wrote this fonction to display directly the incoming image. curl_easy_setopt require a fonction with the same prototype thant fwrite. I wrote this :
void update_img(void *ptr, size_t size, size_t nmemb, void *stream)
{
img_position.x = 0;
img_position.y = 0;
webcam_img = IMG_Load(ptr);
SDL_BlitSurface(webcam_img, NULL, screen, &img_position);
SDL_Flip(screen);
pause();
}
It doesn't work because the IMG_Load argument needs to be the path to a file (stored in an const *char). So I'm searching for an SDL function which can display an image directly from a pointer.
Many thanks in advance for your help.
PS : I use the latest SDL devel lib on MacOSX with Xcode.
_________________________________________________________________
Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et gagnez du temps avec l'interface à la Outlook !
http://www.windowslive.fr/hotmail/default.asp
More information about the SDL
mailing list