Android : save a Bitmap to bmp file format

(I’m answering my own question) Here is my current solution. It is derived from this source : https://github.com/ultrakain/AndroidBitmapUtil (thanks to ultrakain and @Francescoverheye ) I just fix a little bug in computation of the dummy bytes that must be added to each row (so that the length of each row in bytes is a multiple … Read more

How can I read BMP pixel values into an array?

and ready to go code, tested with g++ (not Windows, but may help someone): #pragma pack(1) #include <iostream> #include <fstream> #include <vector> using namespace std; #include “bmp.h” vector<char> buffer; PBITMAPFILEHEADER file_header; PBITMAPINFOHEADER info_header; void fill() { std::ifstream file(“data.bmp”); if (file) { file.seekg(0,std::ios::end); streampos length = file.tellg(); file.seekg(0,std::ios::beg); buffer.resize(length); file.read(&buffer[0],length); file_header = (PBITMAPFILEHEADER)(&buffer[0]); info_header = (PBITMAPINFOHEADER)(&buffer[0] … Read more

read pixel value in bmp file [closed]

The following code snippet is not complete, and contains lots of hidden assumptions and bugs. I wrote it from scratch for a university course project from mere observation, where it minimally fulfilled all the requirements. I didn’t work on it any more, because there must be libraries that would do the job way better. Here … Read more