Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending an Labview Image to a .Net program

Solved!
Go to solution
I have a labview vi that grabs a color image from a camera and displays it. I would also like to send this image to a different machine over TCP or Datasocket to a .Net program (the language is not important to me) that would display it. I am not sure of what is the most efficient method/respesentation for the Labview image that would make it easy to restore this image into a .Net Bitmap.

Thanks in advance,

Michael Terk
0 Kudos
Message 1 of 2
(3,309 Views)
Solution
Accepted by topic author M.T.
One way you could to this would be to save the image in some known format (I used bitmap) to a file. Then you could read back the file in the form of a byte array. This would give you the image byte stream that you can send over the network (tcp or datasocket, it should'nt matter, datasocket was easier). Once your .NET app receives the data, you can cast it into a byte array and display the image like so

private void dataSocket1_DataUpdated(object sender, NationalInstruments.Net.DataUpdatedEventArgs e)
{
object data= e.Data.Value;
if(DataConverter.CanConvert(data,typeof(byte[])))
{
byte [] bytearray;
bytearray = (byte[])DataConverter.Convert(data,typeof(byte[]));
if(bytearray.Length > 1)
{
pictureBox1.Image = new Bitmap(new MemoryStream(bytearray));
}
}

}

Dataconverter is a Measurement Studio class that makes the casting process easier. I could'nt figure out how to convert the LV image data to a bitmap in memory, otherwise you would'nt need to save the file. One possible route would be to see how the Write Bitmap File.vi does it and use that to build a byte array that you could pass to datasocket.

Hope this helps. The example uses LV 7.1 and MStudio 7.1
Bilal Durrani
NI
Message 2 of 2
(3,299 Views)