LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

display a picture generated by a .net dll

Solved!
Go to solution

Hi community,

I'm facing an issue when I want to display a picture (barcode) generated by a .Net Library made by a colleague.

I create with labview an object call "barcode" from this Library and invoke the node barcode which is returning a System.Drawing.Image and I can't display this Image on labview.

 

Someone has already done something similar?

You will find attached the dell and VI I wrote.

 

 

Download All
0 Kudos
Message 1 of 11
(4,170 Views)
Save to LV14 or earlier, please.
0 Kudos
Message 2 of 11
(4,143 Views)

Hi,

Here is the LV 2014 version

0 Kudos
Message 3 of 11
(4,131 Views)

From the Bitmap, you'll need to get the Width and Height properties, and then use GetPixel(X,Y) to build a 2D array. Then convert that to a pixmap using Unflatten Pixmap, and then (if required) to a picture control with Draw Flattened Pixmap.

 

Note that the dll doesn't load correctly (or run), there are probably missing dependencies.

Message 4 of 11
(4,123 Views)
Solution
Accepted by topic author NicolasChristnacher

 


when you feed the "encode" reference into a generic property node, spawn some indicators e.g. "height" and run the .vi,

this is happening:

image-empty.png

 

so, either your input parameters result in an empty image, or as wiebe suggested:

 

wiebe@CARYA wrote:

Note that the dll doesn't load correctly (or run), there are probably missing dependencies.

 

EDIT: already the first "bar code" methode node indicates

1386 error

after running the .vi

Message 5 of 11
(4,107 Views)

Thanks for your answer,

I wrote to the dll developper and wait for his answer

0 Kudos
Message 6 of 11
(4,075 Views)

I modify width and height inputs value and it's working but I have something strange: the picture box is erased once run is finish, if I want to see the barcode in the picture box I have to run continuously.

0 Kudos
Message 7 of 11
(4,068 Views)

When the VI stops, it releases some resources. Continuous run is probably not needed, but you'll have to make sure the VI doesn't stop. For instance, drop a Wait with 10000 ms, or an event structure on the diagram to prevent the VI from going to idle.

Message 8 of 11
(4,060 Views)

LabVIEW closes references after a run, so that sounds reasonable. If you just add a wait or have it as part of a bigger program it shouldn't be a problem.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 11
(4,052 Views)

Usually, I'd avoid .NET objects but in stead get LabVIEW data asap.

 

It is not easy, but possible, to get a LV Pixmap from the image. See attached VI saved to LV2013.

 

Note that I get your image from file. You should be able to figure that out. Also note it's not been tested very toughly. There might be memory leaks or even crashes, since the marshal object relates to "unmanaged" data (pointer stuff). It seems fine though.

Message 10 of 11
(4,049 Views)