Discussion:
problems creating a BMP file
(too old to reply)
Kaspar
2008-08-06 14:40:09 UTC
Permalink
Hello,
 
 
    I am getting screen shot data from various instruments with the VISA read command, which outputs a string of data.  How do I convert this to a 2d array so that I create a BMP file?
 
Regards,
 
Kaspar
smercurio_fc
2008-08-06 14:40:12 UTC
Permalink
Well, that depends on the format of the 2D data, and what the 2D data represents. This should be documented in the instrument's manual, which we don't have.
Kaspar
2008-08-06 15:10:06 UTC
Permalink
Hello,
 
   I am getting BMP data from 2 differenet manufacturers. I will contact them to get the format. So once I get the format  how would I convert the output of the VISA read (which is string data) to the input that the Write BMP File vi needs which is image data?
 
Regards,
 
Kaspar
MikeS81
2008-08-06 15:10:07 UTC
Permalink
Hi Kaspar,
i think your "string" data is a binary byte stream. If you know the format you can convert your data to an array of U8 and build your picture of it.
Hope it helps.Mike
Kaspar
2008-08-06 15:10:09 UTC
Permalink
Hello,
 
  Yes your are correct this is a binary data string from the instrument. I will try what you suggested. thank you!
Regards,
 
Kaspar
 
 
Dennis Knutson
2008-08-06 15:10:10 UTC
Permalink
And have you tried simply saving the data directly to disk?
Kaspar
2008-08-06 15:10:12 UTC
Permalink
Hello,
   Yes I have tried writing the data directly to a file and have looked at it with binary file viewers. The file created does not have the BMP header info, it appears to just have the bitmap data. So it looks like I have to figure out how to convert  from the output of the VISA read, which is the binary data to image data, which is what the Write BMP file needs for a input.
Regards,
 
Kaspar
 
 
  
Mythilt
2008-08-06 15:40:05 UTC
Permalink
Something like the vi attached is probably what you need.
You will need to modify it according to the specifics of your data.
 


ConvertStringtoBitmapExample.vi:
http://forums.ni.com/attachments/ni/170/347105/1/ConvertStringtoBitmapExample.vi
Kaspar
2008-08-06 15:40:05 UTC
Permalink
Hello,
 
  I am using Labview 8.2, the vi you attached is in 8.5. Could you PLEASE (I have used the magic word) save the vi in 8.2 and post it?
Regards,
 
Kaspar
Mythilt
2008-08-06 16:10:07 UTC
Permalink
Soitanly.
 
v8.2 version attached.


ConvertStringtoBitmapExample.vi:
http://forums.ni.com/attachments/ni/170/347132/1/ConvertStringtoBitmapExample.vi
Kaspar
2008-08-06 16:10:11 UTC
Permalink
Hello,
 
  Thanks for posting the 8.2 version. Now I have to contact the vendors to get the image res and size of the screenshot data.  Presently the programmers guides just state BMP format, there is no indication of res and/or size.
 
Regards,
 
Kaspar
 
Kaspar
2008-08-11 14:10:06 UTC
Permalink
Hello,
  Success....drum roll please (I have used the magic word). I have been able to get a screen shot from a TDS2022 scope. I have attached the vi to this E-mail, it is written in Labview 8.2. If you have questions, please reply to this forum.
Regards,
 
Kaspar
 
  


tds2022_screen_capture.vi:
http://forums.ni.com/attachments/ni/170/348247/1/tds2022_screen_capture.vi
Kaspar
2008-08-11 17:10:05 UTC
Permalink
Hello,
 
   I got so excited about fixing the screenshot with the TDS2022 that I forgot to save the vi to disk before I appended it to the website. So here it is again, this time it is the vi that works. Sorry for the confusion.
 
Regards, Kaspar
 


tds2022_screen_capture.vi:
http://forums.ni.com/attachments/ni/170/348336/1/tds2022_screen_capture.vi
Mythilt
2008-08-11 21:40:04 UTC
Permalink
So the program works now?  Excellent, and good job.
Kaspar
2008-08-12 12:10:12 UTC
Permalink
Hello,
 
  The vi I supplied above works at least for me in my program. Hopefully someone else will use it in their program to get a screenshot of the scope.
Regards,
 
Kaspar

smercurio_fc
2008-08-06 15:40:06 UTC
Permalink
I think an easier solution is to use the Flatten Pixmap function to generate that cluster. You just need to know what bit-depth you're dealing with so you wire to the appropriate input.
Kaspar
2008-08-06 16:10:06 UTC
Permalink
Hello,
 
  I have used the "String to byte Array" vi to convert from the string output of a VISA read to a u8 1d array. Unfortunately, the Flatten Pixmap vi, requires a 2d array input. So how would I convert this into a 2 day array for the flatten pixmap vi?
Regards,
 
Kaspar
Mythilt
2008-08-06 16:10:08 UTC
Permalink
Kaspar wrote:

Hello,
 
  I have used the "String to byte Array" vi to convert from the string output of a VISA read to a u8 1d array. Unfortunately, the Flatten Pixmap vi, requires a 2d array input. So how would I convert this into a 2 day array for the flatten pixmap vi?
Regards,
 
Kaspar


If you know the size of the image (width / Height) you use the reshape array function.
smercurio_fc
2008-08-06 16:10:08 UTC
Permalink
I have used the "String to byte Array" vi to
convert from the string output of a VISA read to a u8 1d array.
Unfortunately, the Flatten Pixmap vi, requires a 2d array input. So how
would I convert this into a 2 day array for the flatten pixmap vi?
<img src="Loading Image..."> Message Edited by smercurio_fc on 08-06-2008 10:44 AM


reshape array.png:
http://forums.ni.com/attachments/ni/170/347133/1/reshape array.png
Continue reading on narkive:
Loading...