How to generate a BMP file header with Arduino IDE?

I generated some BMP files with Arduino IDE , but they are only datas not a real BMP file , I know if I want to work the BMP file , the prerequisite is the header , I tried violence writing to the file , but it was failed!(As expected joke!)

Get down to business , how to insert BMP's header with Arduino IDE?

Use paint to store an image in the exact size u will be using.
Then use eg. "hexedit" to fetch the header.

also see this link

knut_ny:
Use paint to store an image in the exact size u will be using.
Then use eg. "hexedit" to fetch the header.

also see this link

Sorry,I don't know what you mean

It will basically come down to writing bytes directly to the file in the right format, then writing the pixel data after that.

You'd need to read and understand the bitmap file format, I found Wikipedia to be good enough when I recently had to parse BMP files for a specific purpose:

For your purposes, you probably want to implement something like example 1 in the wikipedia article. Biggest change is figuring out what the header values need to be for RGB565 (16 bit) data (the usual used on Arduino) - the example shows RGB888 (24 bit) instead. At a guess, you will need to write out

  • Bitmap file header (14 bytes)
  • DIB header (version BITMAPINFOHEADER, 40 bytes), with compression BI_BITFIELDS and color depth 16
  • 12 bytes that describe the RGB565 pixel format
  • Your actual pixel data.

Good luck, and have fun!