Showing results for 
Search instead for 
Did you mean: 

How to convert the byte array into an image file

Hi. Now i'm working on convert the byte array into an image file.

I have to use Labview coms so cannot use graphic functions in labview such as open jpg file or unflatten bitmap and so on.


I've tried on 'write a binary file' or 'write a text file' but it seems like there's no compatibility.

When I use 'write a binary file', the size comes out in a right way. However, cannot open the file.

Even though the byte array is a right one when I convert it into byte array again.


And when I use 'write a text file', I can open the file but there's a lot of noise as I attached behind.

and the size of the file is a bit larger.



I uploaded what i programmed. If you give me a answer it'll be very thankful.


*I've also tried change bitstream to base 64 codes and save it thru 'write a text file' but no effect.

Download All
0 Kudos
Message 1 of 6

Try Picture to pixmap and write the cluster to a binary file, that should be easy to read back also.


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

Qestit Systems
0 Kudos
Message 2 of 6

When you say "image file", do you mean a graphical file in a format such as PNG or JPEG or GIF, that you can then open with other software? Those each have their own specific formats for storing image data, they're not just a raw array of pixel data. You need to follow the proper format for the file type you're creating.

0 Kudos
Message 3 of 6

Oh sure this can be done a couple of ways.  If you have your byte stream as a PNG file LabVIEW has a single function that converts from the byte stream to the LabVIEW Image Data format.  Otherwise you can use some .Net to open the image, then save it as a PNG stream, and use that.  Attached is an example.  This should support most common image file types.


Parts of this code come from my Image Manipulation code that opens and scales just about any image type to a pane in LabVIEW without needing code to run on the pane resize.

Message 4 of 6

but i don't understand why the byte array isn't converted into the right file, even if i open a jpg file and save it as a jpg file which has a same format.

I understand there are several headers which infers the information of data

but i don't understand why it has to be converted into an image data even though the byte array is much shorter than that.


0 Kudos
Message 5 of 6

If you want more detailed help you're going to have to share your actual code, not a picture of it.

0 Kudos
Message 6 of 6