[Gambas-user] Download JPG with HttpClient to memory
EA7DFH
ea7dfh at ...2382...
Tue Feb 15 23:03:43 CET 2011
Hi list
I am unable to download a JPG image from an IP Webcam and feed a
PictureBox, without creating a file-like object.
I'm using HttpClient to fetch the images asyncronously, but the buffer
at last is only a string representation of its binary data.
How do I convert this data into an actual image object for viewing in a
PictureBox or DrawingArea?
This is my code so far:
' Gambas class file
PUBLIC $http AS HttpClient
PRIVATE $pic AS String
PUBLIC SUB Form_Open()
$http = NEW HttpClient AS "MyStream"
$http.Async = TRUE
$http.Timeout = 3
$http.URL = "http://192.168.1.10:4500/axis-cgi/jpg" &
"/image.cgi?resolution=320x240"
END
PUBLIC SUB Timer1_Timer()
$http.Get
END
PUBLIC SUB MyStream_Read()
DIM buffer AS String
READ #LAST, buffer, Lof(LAST)
$pic &= buffer
END
PUBLIC SUB MyStream_Finished()
' Here I want to feed the picturebox with the buffered JPG
' but $pic only contains a string repr of the binary image
PictureBox1.Refresh
END
PUBLIC SUB btnStart_Click()
Timer1.Start
END
PUBLIC SUB btnStop_Click()
Timer1.Stop
END
PUBLIC SUB btnExit_Click()
Timer1.Stop
ME.Close
END
I'd like to avoid using a file, is it possible to do from RAM?
Gambas 2.22
Linux Mint 10 (based on Ubuntu 10.10)
Gnome desktop.
Regards
--
Jesus, EA7DFH
More information about the User
mailing list