Download bmplib on github.
successful results from reading sample images from Jason Summers’ fantastic BMP Suite:
Questionable files that failed:
To install the latest development version of the library under the default
/usr/local
prefix on debian-like Linux:
sudo apt install build-essential git meson pkg-config
git clone https://github.com/rupertwh/bmplib.git
cd bmplib/
meson setup --buildtype=release mybuilddir
cd mybuilddir/
ninja
ninja install
Receive updates:
cd bmplib/
git pull --rebase
cd mybuilddir/
ninja
ninja install
A minimalistic meson.build
for a program that uses bmplib:
project('mytest', 'c')
bmpdep = dependency('libbmp')
executable('mytest', 'main.c', dependencies: [bmpdep])
Includes:
#include <bmplib.h>
see API-quick-start.md and API-full.md for the API documentation
64bit BMPs are a special breed. First of all, there is very little information about the format out there, let alone an ‘official’ spec from MS. It seems that the RGBA components are stored as s2.13 fixed-point numbers. And according to Jason Summers’ BMP Suite the RGB components are encoded in linear light. As that’s the only sample of a 64-bit BMP I have, that’s what I am going with for now. But that also means that there is no one obvious format in which to return the data.
Possible choices are:
Choice 3 (16bit sRGB gamma) seems to be the most sensible default (and I made it the default), as it will work well for all callers which are not aware/don’t care about 64bit BMPs and just want to use/diplay them like any other BMP. (Even though this goes against my original intent to not have bmplib do any color conversions.)
Note: the s2.13 format allows for negative values and values greater than 1! When converting to 16bit integers, these values will be clipped to 0…1. In order to preserve the full possible range of 64bit BMP pixel values, the number format should be set to either BMP_FORMAT_FLOAT or BMP_FORMAT_S2_13.
bmplib provides these functions to check if a BMP is 64bit and to set the conversion:
bmpread_is_64bit()
bmpread_set_64bit_conv()
bmp_set_number_format()
As to writing BMPs, by default bmplib will not write 64bit BMPs, as they are so exotic that only few applications will read them (other than native Microsoft tools, the new GIMP 3.0 is the only one I am aware of).
Use bmpwrite_set_64bit()
in order to write 64bit BMPs.
Cheers,
Rupert
bmplibinfo@gmail.com
(be sure to include ‘BMP’ anywhere in the subject line, otherwise mail will go straight into spam folder)