> 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?
> 

At the moment, no.

But if you get the HTTP answer, save it to /tmp, reload it as a picture, and 
delete the file, there is a good chance that the file does not hit the disk at 
all. And if you have a /tmp that is mounted on a RAM file system, it is almost 
sure!

Regards,

-- 
Benoît Minisini

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to