Support for reading/writing 1 bit (black/white) BMP images?
- Dominant language
- C++
- Stars
- 199
- Forks
- 171
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 10
Description
### Actual behavior
Attempting to read the attached monochrome BMP image using gil will result in an "Image types aren't compatible" exception being thrown from io_error() in error.hpp.
### Expected behavior
Valid load of a valid 1-bit BMP image on the gil::read_image() call;
### C++ Minimal Working Example
```cpp
#include
#include
#include
namespace gil = boost::gil;
int main()
{
std::ifstream infile("test1bpp.bmp", std::ios::binary);
gil::rgb8_image_t img; // <-- This line probably is not correct, but don't know what this should be
gil::read_image(infile, img, gil::bmp_tag());
}
```
I am new to gil, and more than likely, the img type is not correct, which is not surprising. However I was not able to use any of the other types that are predefined without compilation error from the template compile checks, or if the compilation succeeds, the same exception being thrown at runtime ("Image types not compatible").
So I am not sure if 1-bpp images are supported in gil, and/or what should be done in the existing gil library to read the attached image.
### Environment
- Compiler version: Visual Studio 2019
- Build settings: Debug / Release / 32-bit
- Version (Git ref or ``): 1.81
[test1bpp.zip](https://github.com/boostorg/gil/files/10714953/test1bpp.zip)
Contributor guide
Research direction
Start with boost/gil/extension/io/bmp.hpp and the error path in error.hpp, then reproduce the failure using the attached test1bpp.zip and the provided C++ example. Check how BMP bit depths are mapped to GIL image types and whether writing is handled by the same path. Done means valid 1-bit BMP images can be read, with writing behavior clarified or covered as appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100