ā11-01-2012 06:05 AM
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
ā11-01-2012 06:12 AM
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.
ā11-01-2012 06:58 AM
Thanks Dan. Would you please show me how to do it in a very basic example. I tried it didn't work for me.
ā11-01-2012 07:07 AM
It's really simple, see snippet.
ā11-01-2012 07:56 AM
Great .Many thanks. Would you please also let me know how can I recover the picture from bit stream or Text to JPG again
ā11-01-2012 07:58 AM
Just write the text to a binary file using the corresponding function (Write to Binary File).
ā11-01-2012 10:35 AM
I tried this code but it is not working
ā11-01-2012 10:42 AM - edited ā11-01-2012 10:42 AM
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.