08-09-2021 04:50 PM
Hi Guys,
I have a weird issue with a bmp file that I'm trying to use Read BMP File VI on. It's generated from a camera. With the bmp file as is from the camera, I get "Read from Binary File in Read BMP File Data.vi" with error code 1. If I open the bmp file with infranview and save it as a bmp file, I get no error in Read BMP File Data.vi.
Anyone happen to know the solution? It seems that I'm not the first (example) to run into something odd.
Solved! Go to Solution.
08-09-2021 05:44 PM
There are so many different bmp formats that I'm not surprised that that particular one is not supported.
08-09-2021 05:53 PM
It would be helpful to post an example image that doesn't work and the converted one that does.
08-10-2021 07:27 AM
@BertMcMahan wrote:
It would be helpful to post an example image that doesn't work and the converted one that does.
Yeah, I wish I could. Most of the images are proprietary, so I would have to take special image of something random to do this. I can probably do that if needed, but I did just discover that the "issue bmp" image has 32 bit depth while the "infranview bmp" has 24 bit depth.
Does that difference in bit depth explain the error in Read BMP File Data.vi?
08-10-2021 07:45 AM - edited 08-10-2021 07:46 AM
@WavePacket wrote:
@BertMcMahan wrote:
It would be helpful to post an example image that doesn't work and the converted one that does.
Yeah, I wish I could. Most of the images are proprietary, so I would have to take special image of something random to do this. I can probably do that if needed, but I did just discover that the "issue bmp" image has 32 bit depth while the "infranview bmp" has 24 bit depth.
Does that difference in bit depth explain the error in Read BMP File Data.vi?
This is what I expected. LabVIEW does not support 32 bit bmp files. (I don't know if it supports any 32-bit image formats.) See here.
The detailed help for a function is very helpful - and detailed, of course.
08-10-2021 08:03 AM
Yeah, Ok. So I guess my need now is to convert the bit depth programmatically somehow. Is that possible?
08-10-2021 08:18 AM
@WavePacket wrote:
Yeah, Ok. So I guess my need now is to convert the bit depth programmatically somehow. Is that possible?
Sure. Irfanview and other image conversion programs also support a command line interface. Easy to call with System Exec in LabVIEW.
Or you can hack into the LabVIEW VIs and add support for 32 bit BMP images if you really want to know how these things work. But beware, image format handling is a very tedious and nasty low level business and requires some specific abilities that are not commonly used in other LabVIEW programming (nor most any other programming).
08-11-2021 07:52 AM
In-case this helps someone else, here is the code snippet of what worked for me.
08-11-2021 09:07 AM - edited 08-11-2021 09:07 AM
Also you can probably load the image in a .Net Picturebox. Here is some code I posted for displaying an image and having it scale without needing custom code.
https://forums.ni.com/t5/LabVIEW/Read-multi-image-tiff/m-p/3580103#M1002365
I don't have a 32-bit BMP to test with, but it handles other alpha layer transparencies in PNG files just fine.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-11-2021 09:50 AM
@Hooovahh wrote:
Also you can probably load the image in a .Net Picturebox. Here is some code I posted for displaying an image and having it scale without needing custom code.
https://forums.ni.com/t5/LabVIEW/Read-multi-image-tiff/m-p/3580103#M1002365
I don't have a 32-bit BMP to test with, but it handles other alpha layer transparencies in PNG files just fine.
I just downloaded the image zip but when loading "Demo Load Image.vi" it said that it was missing "Current VIs Parent Directory_ogtk.vi". Any thoughts?