Is there any straightforward way to do this? I am ready to do this from scratch, but only if any readymade solution is not available.
I can't tell you if there are readymade solutions to write BMP in iOS, but I can tell you that BMP is one of the few formats that is relatively easy to write from scratch.
Create a bitmap header, following the file format. I am not sure whether all bmp versions (1 bit, 8bit etc) has same header format. Couldn't find any information on that.
The Wikipedia article is quite informative. All BMP types have basically the same header format, the bitdepth is stored in offset 1Ch
Iterate through all pixels of the png image, get the byte value of Red, Green, Blue (RGB). Do some calculation on these 3 values, to get a 1 bit representation. For example ... Append these bits to bmp header which you already created.
Sounds right. Don't forget that rows can require some padding
But I have no idea how to deal with bits
Simply pack group of eight bits in one byte.