BMP libraries for C/C++
- stb_image (
stb_image.h+stb_image_write.h) is a public-domain single-header loader and writer. It reads uncompressed 1 to 32-bit BMP files and writes 24-bit BMP, or 32-bit with alpha. It doesn’t read RLE-compressed files. - SDL has BMP support built in:
SDL_LoadBMPreads uncompressed and RLE files into anSDL_Surface,SDL_SaveBMPwrites 8, 24 or 32-bit files. Pick it if your program already uses SDL.
BMP is simple enough that many programs write it without a library: a 24-bit BI_RGB file is a 54-byte header followed by BGR rows padded to 4 bytes (see the file structure). For other formats as well, ImageMagick (MagickWand) and FreeImage also read and write BMP. On Windows, WIC and GDI+ read and write BMP but aren’t open source.
- SDL SDL (Simple DirectMedia Layer) loads and saves BMP files with SDL_LoadBMP and SDL_SaveBMP. How to read a BMP into a surface, access pixels.
- stb_image stb_image and stb_image_write are single-header public domain C libraries to load and save BMP images. How to load a BMP, get its size, write 24-bit.