ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a C# code sample using ImageToArray and ArrayToImage?

I am looking for a C# code sample using the CWImaqImage methods ImageToArray() and ArrayToImage().
 
When I try the following:
 

using NationalInstruments;

using

NationalInstruments.CWIMAQControls;

CWIMAQImage srcImage = new CWIMAQImage();

CWIMAQImage destImage = new CWIMAQImage();

byte[] bufferArray = new byte[640 * 480];

srcImage.SetSize(640, 480);

srcImage.Type =

CWIMAQImageTypes.cwimaqImageTypeU8;

srcImage.ArrayToImage((

Object)bufferArray);

...perform image processing operations -> destImage

bufferArray = (

byte[])destImage.ImageToArray(0,0,640,480)

I get a runtime exception when ArrayToImage() is called: COMException was unhandled by user code - "You have passed an invalid type into a parameter of a VARIANT type."
 
Any sample code using these two methods would be appreciated.
 
 
 
0 Kudos
Message 1 of 3
(4,382 Views)
Hi mpu,
 
Unfortunately, I do not have a quick answer to this one. I am looking into this and will post back to this thread as soon as I have a answer for you.
--Michelle

National Instruments
0 Kudos
Message 2 of 3
(4,360 Views)
Hi mpu,

I've attached an example of how to do this. To use this function, you do not need to pass an object but can pass an array of integers.

Does this make sense?


--Michelle

National Instruments
0 Kudos
Message 3 of 3
(4,285 Views)