判断 (位数 = 24 ) 计次循环首 (h, y )  计次循环首 (w, x )   位图 = 位图 + 字节集反转 (取字节集左边 (到字节集 (颜色表 [x ] [h + 1 - y ]), 3 ))   计次循环尾 ()  如果真 (取字节集长度 (位图 ) ÷ 4 ≠ 到整数 (取字节集长度 (位图 ) ÷ 4 ))    位图 = 位图 + 取空白字节集 ( (1 - 取字节集长度 (位图 ) ÷ 4 + 到整数 (取字节集长度 (位图 ) ÷ 4 )) × 4 ) 处理事件 () 计次循环尾 () 位图 = { 66, 77 } + 到字节集 (到整数 (58 + 取字节集长度 (位图 )) ) + { 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0 } + 到字节集 (w ) + 到字节集 (h ) + { 1, 0, 24, 0, 0, 0, 0, 0 } + 到字节集 (取字节集长度 (位图 )) + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + 位图   
代码如上所示,其中 到字节集 (到整数 (58 + 取字节集长度 (位图))) 中的58应该为54。
bmp头的前第3-6字节应该是整个BMP的大小。我发现生成24位的BMP比实际大小到了4。代码后面的{ 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0 } 也明确了位图信息偏移量为54,而不是58。
当然如果是我理解有误请指出文件头为58的原因。
|