QDBMP (Quick n' Dirty BMP) is a minimalistic cross-platform C library for handling BMP image files. The library is extremely lightweight - it consists of just two small files and has no dependencies other than the standard C library. It is intended to provide small applications with basic image I/O capabilities by utilizing the widely used BMP image format.
The library is written entirely in C, and is highly portable. It explicitly handles endianness issues and uses no OS-specific code.
The library supports the following BMP variants:
- Uncompressed 32 BPP (alpha values are ignored)
- Uncompressed 24 BPP
- Uncompressed 8 BPP (indexed color)
QDBMP is free and open source software, distributed under the MIT license.
qdbmp_0.1.0.tar.gz - QDBMP version 1.0.0 (UNIX newlines) (2007-04-07, 8 KB)
qdbmp_0.1.0.zip - QDBMP version 1.0.0 (Windows newlines) (2007-04-07, 10 KB)
Add qdbmp.h and qdbmp.c to your project. Include qdbmp.h in your code.
BMP - Bitmap object instance
UINT - Unsigned long integer (DWORD)
USHORT - Unsigned short integer (WORD)
UCHAR - Unsigned char
QDBMP's functions do not return values indicating success. Instead, each library operation sets an internal flag that may be queried using BMP_GetError(). If the operation was successful the function returns BMP_OK. Otherwise, it returns an error code describing what went wrong. BMP_GetErrorDescription() may be used to get a textual description of the last error that has occurred.
The suggested style is checking for an error immediately after every error prone operation. The BMP_CHECK_ERROR macro may be used to simplify this process. To illustrate:
Creates a blank BMP image with the specified dimensions and bit depth.
Frees all memory used by the BMP image.
Reads the specified BMP image file.
Writes the BMP image to the specified file.
Returns the image's width.
Returns the image's height.
Returns the image's color depth (number of bits per pixel).
Populates the arguments with the specified pixel's RGB values.
Sets the specified pixel's RGB values.
Gets the specified pixel's color index.
Sets the specified pixel's color index.
Populates the arguments with the RGB values for the specified palette index.
Sets the RGB values for the specified palette index.
Returns the last error code.
Returns a textual description of the last error.
May be used after each BMP operation to check for an error. If an error has occurred, its description is printed to the specified output file and the specified value is returned.
QDBMP is developed by Chai Braudo.