LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save binary 2D array to .bmp file??

Solved!
Go to solution

Hi,

 

I am new to LabVIEW...

 

I have a binary 2D array and I would like to save it to .bmp file. The .bmp file has to be 1-bit bit depth in order to meet the devide requriement.

 

I tried to use flatten pixmap but it only has 4-, 8-, 24-bit pixmap options for 2D array. 1-bit pixmap is for the boolean array input.

 

I don't know how to convert the binary 2D array into the boolean array or any other method to fix this problem.

 

I appreciate ya'll's help.

 

Thanks,

Jinyang

0 Kudos
Message 1 of 5
(3,579 Views)
Solution
Accepted by topic author Jinyang

Hi Jinyang,

 

don't know what you understand by "binary 2d array", but I would suggest something like this:

bmp.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,568 Views)

Thanks! It works really well now!!

 

But now I have got another problem. Since the bit depth is only 1, I can only enter 2 color element for display. So, I tried 0 and 1 but it didn't show up very well. Then, I tried some larger number like 127 or 255 and it display as black (0) and blue (255).

 

I wonder if there is a way to display the .bmp binary file on only black and white color.

 

Thanks,

Jinyang

0 Kudos
Message 3 of 5
(3,542 Views)

Hi Jinyang,

 

you have to give real color values...

Until now you only gave the index of the color (0 and 1), but colors itself are given in RGB values. Either use the color constant (found nearby the picture file functions) or a standard U32 constant (switched to hex display). Then set your colors. When using an U32 you have to give the value of each color component. Red is 0x00FF0000, green=0x0000FF00, blue=0x000000FF, white=0x00FFFFFF, black=0x00000000. Do you get the scheme?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(3,526 Views)

Great! It works really well!! Thank you so much!!

0 Kudos
Message 5 of 5
(3,492 Views)