Example Code

Create bitmap (BMP) files step by step using binary file functions

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • LabVIEW

Code and Documents



This VI creates bitmap files. It takes care of all of the required portions of the BMP file format by creating file header, file info header and the data array step by step. Low level binary file functions are used to write BMP file content.



For demonstration purposes an example PNG file will be loaded first and converted to 24 bit pixmap. The resulting 24 bit pixmap array can easily be converted to a 3D 8 bit unsigned integer array which is required when writing BMP image data. This conversion but also the BMP file header creation are demonstrated in this example. The example can easily be modified to write your own image data to a BMP file. There are separate SubVIs for File header, File info header and data array creation.



  • LabVIEW Base Development System 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)


  • No hardware is necessary to use this example VI


Steps to Implement or Execute Code

  1. Download and extract the attached file "Bitmap File Writer LV2012 NIVerified.zip"
  2. Follow the instructions in Front Panel of "[Main] Bitmap File Writer LV2012 NIVerified.vi" and run the program


Additional Information or References

[Main] Bitmap File Writer LV2012 NIVerified.vi - Front Panel.png


[Main] Bitmap File Writer LV2012 NIVerified.vi - Block Diagram.png


**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

Wes Pierce
Principal Engineer
Pierce Controls

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.


Could you please add some pictures of maybe even a Snippet?