Hi forum,
I’m running in various exceptions on client side when i try to display a image, send by a webserver.
My configuration:
CLIENT: Spider 1.0, Wifi RS21, SDK 2015 R1
SERVER: Spider 1.0, Wifi RN71, Serial Camera L1, SDK 2015 R1, RoSchmi Driver v8 [url]https://www.ghielectronics.com/community/codeshare/entry/927[/url]
I’m sending text data stable without problems on this system (thx to Roschmi).
On the server side i prepare my image bevor i send like this:
request.Response.HeaderData["Content-type"] = "images/bmp"; // jpeg ?
request.Response.HeaderData["Connection"] = "close";
request.Response.HeaderData["Cache-Control"] = "no-cache";
request.Response.StatusCode = GTM.GHIElectronics.HttpResponse.ResponseStatus.OK;
serialCameraL1.StartStreaming();
while (!serialCameraL1.NewImageReady);
// i get a correct sized array with data (160 x 120 * 3 + 54)
byte[] document = GHI.Utilities.Bitmaps.ConvertToFile(serialCameraL1.GetImage());
camera.StopStreaming();
request.Response.HeaderData["Content-Length"] = document.Length.ToString();
request.Response.Send(document, firstBatch, chunkSize, chunkDelay);
The server output window shows me the sending of the complete image.
On the client side i use the code snippet from the documentation to get the array:
byte[] result = new byte[57654];
int read = 0;
using (var req = HttpWebRequest.Create("url to query") as HttpWebRequest)
{
using (var res = req.GetResponse() as HttpWebResponse)
{
using (var stream = res.GetResponseStream())
{
do
{
read = stream.Read(result, 0, result.Length);
Thread.Sleep(20);
} while (read != 0);
}
}
}
No i try the following (and many other things):
// pic is a correct sized array with data
GT.Picture pic = new GT.Picture(result, GT.Picture.PictureEncoding.BMP);
displayT35.SimpleGraphics.DisplayImage(pic, 0, 0); // Exception
displayT35.SimpleGraphics.DisplayImage(pic.MakeBitmap(), 0, 0); // Exception
What am I doing wrong?
Thx for any hlp
dutzend