I know there are quite a lot of topic relating to the "Array to Bitmap Conversion" . However, I cant find one that solved my problem, so I though it would be a good idea to start a new one.
I tried a few ways to save my 2d array in Labview and convert it to a bitmap. The problem is that when I try to open the file on Windows Photo Viewer or Paint, I get :
Windows Photo Viewer cant open this picture because either WPV doesnt support this file format, or you dont have the latest updates to WPV.
I get : Paint cannot read this file. This is not a valid bitmap file, or its format is not currently supported.
On LabView, I use : 2d array > flatten pixmap.vi > draw flattened pixmap.vi > write bmp file.vi
I can display the picture obtained after the draw flattened pixmap VI on the front panel.
My picture is actually very small : it is 8x8 pixels ( each pixel corresponds to the value of a sensor ).
I hope I gave you enough information about my problem. If I can make anything clearer please let me know. Thanks a lot for your help !
Attach your VI. Save your controls and indicators as default, save the VI, then attach it. (That way we can work with the same picture data you are using.)
You wouldn't send an e-mail your mechanic and ask him to troubleshoot your car without ever taking it in and showing it to him.
Thanks for your fast replies.
I tried to save it as PNG but the <write to PNG> VI was stopping the execution of the program. The error code was :
Error 1 occurred at Check Color Table Size.vi
LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
NI-488: Command requires GPIB Controller to be Controller-In-Charge.
The format of the picture data is probably the default one. In fact, I am really new to both Labview and picture formats so it might be the cause of my problem.
In my main program, the numeric block of the subVi is wired to the <i> in my while loop. It changes the name of the bmp file every cycle ( each cycle is around 2 seconds ). The values in the 2d array are between 0 and 5 for now so I am using only 4 bits ( I might want to go from -10 to 10 eventually, with 8 bits resolution ).
I hope I saved the default values the right way and you can see them.
Your error message tells me that something is wrong with your file name. Perhaps the path doesn't exist.
I didn't see that problem.
But I did get a corrupted .bmp file.
I'm suspicious of the use of a 2-D double array into an input that is expecting a 2-D U-8 integer array.
I just tried to wire my 2d array to the 24 bits input of the Flatten Pixmap VI. I scaled my values before so the 0-10 interval is now between 0 -2 to the 24.
I kind of works but the colors look almost random. It think the problem might comes from the colors mapping input of the Flatten Pixmap VI but I dont know how to fix it. Do you think this might be the source of the problem ?
No, scaling a DBL to a 24bit color seems not the right thing to do. What kind of colors do you expect?
I would scale the DBL to 0...255, create a suitable color ramp of 256 colors, and covert to an paletted 8bit image. Works just fne here. See attached for an example (creating greyscale).
This is exactly what I needed. Seems like the color input cant be left blank on the Flatten Pixmap VI. Thanks a lot ! One last thing, is there an easy way to apply the zoom factor to the saved image ? My file is indeed very small.