8-битный BMP
%---- BitMapfileHeader
fwrite(fid, hex2dec('42'), 'uchar'); % 'B' in ASCII code
fwrite(fid, hex2dec('4D'), 'uchar'); % 'M' in ASCII code
fwrite(fid, 54 + sz + 256 * 4, 'ulong'); % file size
fwrite(fid, 0, 'ushort'); % always 0
fwrite(fid, 0, 'ushort'); % always 0
fwrite(fid, 54 + 256 * 4, 'ulong'); % offset
%---- BitMapInfoHeader
fwrite(fid, 40, 'ulong'); % BitMapInfoHeader size
fwrite(fid, width, 'long'); % image width
fwrite(fid, height, 'long'); % image height (negative; positive=upside-down)
fwrite(fid, 1, 'ushort'); % always 1
fwrite(fid, 8, 'ushort'); % color bit
fwrite(fid, 0, 'ulong'); % compression
fwrite(fid, sz, 'ulong'); % image size
fwrite(fid, dpm, 'long'); % horizontal resolution (dpm)
fwrite(fid, dpm, 'long'); % vertical resolution (dpm)
fwrite(fid, 256, 'ulong'); % # of color index
fwrite(fid, 0, 'ulong'); % # of important color index
24-битный BMP
%---- BitMapfileHeader
fwrite(fid, hex2dec('42'), 'uchar'); % 'B' in ASCII code
fwrite(fid, hex2dec('4D'), 'uchar'); % 'M' in ASCII code
fwrite(fid, 54 + sz, 'ulong'); % file size
fwrite(fid, 0, 'ushort'); % always 0
fwrite(fid, 0, 'ushort'); % always 0
fwrite(fid, 54, 'ulong'); % offset
%---- BitMapInfoHeader
fwrite(fid, 40, 'ulong'); % BitMapInfoHeader size
fwrite(fid, width, 'long'); % image width
fwrite(fid, height, 'long'); % image height (negative; positive=upside-down)
fwrite(fid, 1, 'ushort'); % always 1
fwrite(fid, 24, 'ushort'); % color bit
fwrite(fid, 0, 'ulong'); % compression
fwrite(fid, sz, 'ulong'); % image size
fwrite(fid, dpm, 'long'); % horizontal resolution (dpm)
fwrite(fid, dpm, 'long'); % vertical resolution (dpm)
fwrite(fid, 0, 'ulong'); % # of color index
fwrite(fid, 0, 'ulong'); % # of important color index
Источник - http://www.h6.dion.ne.jp/~fff/old/technique/matlab/matlab_V.html
Или посмотрите на структуру здесь
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspxhttp://www.herdsoft.com/ti/davincie/davp3xo2.htm
Это намного больше, чем 14 бит ожидаемого OP – usr2564301