LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET bitmap to IMAQ conversion crashing Labview

Solved!
Go to solution

I have a VI that takes a .NET bitmap object and copies its contents into IMAQ image buffer. I do this by converting the IMAQ buffer into it's own .NET reference, then doing a Graphics.DrawImage of the original .NET bitmap into the IMAQ bitmap. The code works fine on my Windows 7, LV 2017x64 computer, but immediately crashes LV on several Windows 8 and 10 machines using 64-bit. Using 32-bit LV, they work fine. I've confirmed all machines have the same .NET Framework and CLR versions. I've installed the F2 updates for LV on at least one of the systems, but it did not help.

 

Using highlight execution, disabling, and various Bitmap formats, I've confirmed that it crashes while in the Graphics.DrawImage invoke node. However, I have (and you can see in the various disabled cases) used other Graphics methods that all result in LV crashing as well. 

 

The crash that happens does not result in the normal LV error reporting window, rather it's a Windows dialog saying the application has stopped working and will close. The Windows event log doesn't seem to contain anything that stands out as helpful.

 

I've attached both the VI that does the conversion and a test VI to load images into both the Bitmap and the IMAQ buffer. I load something into the IMAQ buffer to be able to see that it has changed if successful.

 

Hopefully someone out there has some insight into why this seems to work fine in 32-bit and not 64, but also on 64-bit Win7.

Download All
0 Kudos
Message 1 of 6
(2,005 Views)

Not having LabVIEW 2017 installed on any machine accessible to me at this time. Sorry!

Rolf Kalbermatter
Averna BV
0 Kudos
Message 2 of 6
(1,960 Views)
Solution
Accepted by topic author nzamora

Your storing a U64 in a 32 bit pointer. That won't work!

 

Use IntPrt(int64 value) instead of IntPrt(int32 value)... But only on 64 bit LV, so you need a conditional disabled case to switch between the two.

Message 3 of 6
(1,956 Views)

You just made my week! The IntPtr had come from an example I had found from like 2011 and I just accepted that it was the thing to do without really questioning why. Also the method doesn't visually specify that it's of a specific type, so I never considered looking at it.

 

Well I'm happy to present this code for any who may need it:BitmapToIMAQ.png

Message 4 of 6
(1,945 Views)

Thanks for posting the final VI!

0 Kudos
Message 5 of 6
(1,940 Views)

I've actually made a couple changes since. The format going into the IMAQ Bitmap has to be the same as the imaq itself, not of the source bitmap. Also I added an option to return the IMAQ Bitmap reference since I have some potential need for that as well.BitmapToIMAQ.png

Message 6 of 6
(1,932 Views)