ABOUT
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.
DOWNLOAD
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)
USING QDBMP
Add qdbmp.h and qdbmp.c to your project. Include qdbmp.h in your code.
SAMPLE PROGRAM
API REFERENCE
TYPES
BMP - Bitmap object instance
UINT - Unsigned long integer (DWORD)
USHORT - Unsigned short integer (WORD)
UCHAR - Unsigned char
ERROR HANDLING
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:
FUNCTIONS
BMP_Create()
Creates a blank BMP image with the specified dimensions and bit depth.
BMP_Free()
Frees all memory used by the BMP image.
BMP_ReadFile()
Reads the specified BMP image file.
BMP_WriteFile()
Writes the BMP image to the specified file.
BMP_GetWidth()
Returns the image's width.
BMP_GetHeight()
Returns the image's height.
BMP_GetDepth()
Returns the image's color depth (number of bits per pixel).
BMP_GetPixelRGB()
Populates the arguments with the specified pixel's RGB values.
BMP_SetPixelRGB()
Sets the specified pixel's RGB values.
BMP_GetPixelIndex()
Gets the specified pixel's color index.
BMP_SetPixelIndex()
Sets the specified pixel's color index.
BMP_GetPaletteColor()
Populates the arguments with the RGB values for the specified palette index.
BMP_SetPaletteColor()
Sets the RGB values for the specified palette index.
BMP_GetError()
Returns the last error code.
BMP_GetErrorDescription()
Returns a textual description of the last error.
MACROS
BMP_CHECK_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.
CONTACT
QDBMP is developed by Chai Braudo.