den bardadym den bardadym - 1 year ago 79
C Question

Writing BMP image in pure c/c++ without other libraries

In my algorithm i need create information output. I must to write boolean matrix in bmp file.
It must be monocromic image, where pixel is white if matrix on such element is true.
Main problem is bmp header and how to write this.

Answer Source

Without the use of any other library you can look at the BMP file format. I've implemented it in the past and it can be done without too much work.

Bitmap-File Structures

Each bitmap file contains a bitmap-file header, a bitmap-information header, a color table, and an array of bytes that defines the bitmap bits. The file has the following form:

RGBQUAD aColors[];
BYTE aBitmapBits[];

... see the file format for more details

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download