A single file C++ library to generate Microsoft Windows Bitmap files with minimal dependencies. It depends only on STL.
Just include a header file winbitmap.hpp
. Then you can use winbitmap::canvas
class. Here is an example.
#include "winbitmap.hpp"
int main() {
// Prepare a canvas (width, height)
winbitmap::canvas canvas(256, 256);
// Draw a filled rectangle
canvas.set_color(255, 255, 255);
canvas.fill_rect(0, 0, 256, 256);
// Draw a filled circle
canvas.set_color(255, 0, 0);
canvas.fill_circle(128, 128, 32);
// Draw a line
canvas.set_color(0, 0, 0);
canvas.moveto(0, 0);
canvas.lineto(256, 256);
// Draw a rectangle
canvas.set_color(0, 0, 255);
canvas.draw_rect(32, 32, 64, 32);
canvas.save_to_file("sample.bmp");
std::cout << "Saved to sample.bmp" << std::endl;
}
Then compile and execute the above.
$ g++ test.cpp
$ ./a.out
Saved to sample.bmp
Then you will have the following image.
You can find another example in sample
folder.
$ cd sample
$ make
$ ./a.out
Saved to test3d.bmp
You will have the following image.
This software is released under the MIT License, see LICENSE.