LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a picture to a bit stream

Hi

I would like to convert a picture to a bit stream . I know for example for text to bit we can use "Text to unsigned byte array" block  but I don't know how to do it with lets say a JPG (or any other format). I would greatly appreciate your help with coding or a basic example

0 Kudos
Message 1 of 8
(4,241 Views)

If you have the jpg image as a file you can just read the file using the standard file functions (read binary file). This will return a string. If you need it as byte array you can use the function you mentioned or read the binary file that way.

 

0 Kudos
Message 2 of 8
(4,239 Views)

Thanks Dan. Would you please show me how to do it in a very basic example. I tried it didn't work for me.

0 Kudos
Message 3 of 8
(4,231 Views)

It's really simple, see snippet.

 

Read-binary-file.png

0 Kudos
Message 4 of 8
(4,229 Views)

Great .Many thanks. Would you please also let me know how can I recover the picture from bit stream or Text to  JPG again

 

0 Kudos
Message 5 of 8
(4,224 Views)

Just write the text to a binary file using the corresponding function (Write to Binary File).

 

0 Kudos
Message 6 of 8
(4,222 Views)

I tried this code but it is not working

0 Kudos
Message 7 of 8
(4,207 Views)

In the write primitve, set "prepend array or string size" to False, else it will add 4 extra bytes at the beginning of the file.

 

 

0 Kudos
Message 8 of 8
(4,199 Views)