Microsoft BMP bitmap files
Read and Write Utilities

BMP_IO is a C++ library which reads or writes the graphics information in a Microsoft BMP file.

A user program can employ these routines to read a BMP file and extract and return the graphics information (RGB pixel arrays), or to write internal RGB pixel arrays into a properly formatted BMP file. The BMP file format is used for many of the icons seen cluttering up the desktop of a Windows machine, for instance.

Of course, another interesting application is to read in a BMP file, and write out the RGB information to a file in another format.

Since some of the data is multibyte, the format of the file can depend on whether such data is written with the bytes in "little-endian" or "big-endian" order. The program maintains a variable called BMP_BYTE_SWAP which controls how the program assumes the bytes are ordered. Setting this variable to true show be the appropriate value for little-endian ordering, while false is for big-endian. This variable can be read by calling the function bmp_byte_swap_get, or set by calling bmp_byte_swap_set.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


BMP_IO is available in a C++ version.

Related Data and Programs:

BMP, a data directory which contains example BMP files.

BMP_TO_PPMA, a C++ program which converts BMP files to ASCII PPM format.

BMP_TO_PPMB, a C++ program which converts BMP files to binary PPM format.

PPMA_TO_BMP, a C++ program which converts ASCII PPM files to BMP format.

PPMB_TO_BMP, a C++ program which converts binary PPM files to BMP format.


  1. David Kay and John Levine,
    Graphics File Formats,
    Second Edition,
    McGraw Hill, 1995.
  2. John Miano,
    Compressed Image File Formats,
    Addison Wesley, 1999.
  3. Microsoft Corporation,
    Microsoft Windows Programmer's Reference,
    Volume 5; Messages, Structures, and Macros,
    Microsoft Press, 1993.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C++ source codes.

Last revised on 09 December 2005.