Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain System.Drawing.Image from CWIMAQImage?

What is the best way to obtain System.Drawing.Image from CWIMAQImage? 
 
 
Thanx,
   Michael
0 Kudos
Message 1 of 6
(5,423 Views)
Hey Msush,
 
I always find that the best way to get familiar with the functions is to look through some examples.  The VB examples can be found in C:\Program Files\National Instruments\Vision\Examples\  The example that I am looking at right now is in the "1. Getting Started" folder and is called "Read Image".  This example shows how to set up an image buffer and display the image on a form. 
 
Let me know if this helps you out.
 
Thanks,
 
 
Evan D.
Installer R&D
National Instruments
0 Kudos
Message 2 of 6
(5,375 Views)

Evan,

I don't have

C:\Program Files\National Instruments\Vision\Examples\

folder, but I have

C:\Program Files\National Instruments\NI-IMAQ\Sample\MSVB.NET\Getting Started\Hardware.sln

which, I believe, does similar things.

Unfortunately, it does not answer my question.  I did not ask "How to display the image?", I asked:

How to obtain System.Drawing.Image from CWIMAQImage?

which is a different question.  Right now I am dumping an image to a file and I am reading it back using System.Drawing.  Is there a way to achieve the same without HDD operation?

 

Thank you,

    Michael

0 Kudos
Message 3 of 6
(5,369 Views)
Hello Michael,

I suggest you use the ControlImage method of CWIMAQViewer.  This method returns an image as a Windows Metafile.  You may be able to use this returned image with the "Equals" Image Method to obtain an instance of the System.Drawing.Image class without using file input/output.

Here is an example from the NI Vision for Visual Basic Reference Help that demonstrates how to use the ControlImage method.

Private Sub Run_Click()
'Set the picture property of the picturebox control in VB to
'an image of the CWIMAQViewer control.
Set Picture1.Picture = CWIMAQViewer1.ControlImage
End Sub

Please let me know if you have further questions on this issue.

Best Regards,
T. McCarty

0 Kudos
Message 4 of 6
(5,355 Views)

Hi T. McCarty and other knowledgable NI developers,

 

First, thanks very much for the suggestion of where to look for a method.

 

Unfortunately I believe, if we only have the NI Vision Development Module, we do not have the CWIMAQViewer control.  Besides shouldn't the VisionImage itself offer some way to export, or convert its data to the standard System.Drawing.Image or System.Drawing.Bitmap?

 

Like Michael asked, I am very interested in learning how to quickly (in cpu time) obtain a copy of the VisionImage in one of the two classes above (Image or Bitmap).

 

To be clear, I am not interested in how to display it, or do other things ... I am interested in how to obtain a System.Drawing.Image or System.Drawing.Bitmap from a VisionImage in the most expeditious way.  Hopefully this should be accomplished only using the Vision Development Module without assuming the presence of other development products like Measurements Studio, Labview, etc.

 

I am eager to hear any thoughts you or others may have about it.  Currently I am going down the road of trying to use ImageToArray ... but that seems rather difficult and slow.

 

Thank you in advance for any comments or assistance on the topic.

 

Regards,

New

0 Kudos
Message 5 of 6
(4,203 Views)

 

Ooops ... forgive me I just realized this thread is about CWIMAQImage ... not NI VisionImage ... therefore I may need to find another thread for the preceding question.  Forgive me for my mistake.

 

If you do have any comments about converting VisionImage and feel it is appropriate to place them here please do so.

 

Thanks again

0 Kudos
Message 6 of 6
(4,201 Views)