问题描述
在我的算法中,我需要创建一个信息输出.我需要将一个布尔矩阵写入 bmp 文件.它必须是单色图像,如果此类元素上的矩阵为真,则像素为白色.主要问题是 bmp 标头以及如何编写它.
In my algorithm, I need to create an information output. I need to write a boolean matrix into a bmp file. It must be a monocromic image, where pixels are white if the matrix on such element is true. Main problem is the bmp header and how to write this.
推荐答案
无需使用任何其他库,您可以查看 BMP 文件格式.我过去已经实现过,不需要太多工作就可以完成.
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.
位图文件结构
每个位图文件包含一个位图文件头,一个位图信息头,一种颜色表,以及一个字节数组定义位图位.该文件有以下形式:
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:
位图文件头 bmfh;
BITMAPINFOHEADER bmih;
RGBQUAD aColors[];
BYTE aBitmapBits[];
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
RGBQUAD aColors[];
BYTE aBitmapBits[];
...查看文件格式以获取更多详细信息
... see the file format for more details
这篇关于在没有其他库的情况下用纯 c/c++ 编写 BMP 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)