bmp图像格式

BMP file format

typedef struct bmp_header {
    /* Header */
    char signature[2];
    uint32_t    file_size;
    uint32_t    reserved;
    uint32_t    data_offset;
    /* InfoHeader */
    uint32_t    size;
    uint32_t    width;
    uint32_t    height;
    uint16_t    planes;
    uint16_t    bit_count;
    uint32_t    compression;
    uint32_t    image_size;
    uint32_t    x_pixels_per_m;
    uint32_t    y_pixels_per_m;
    uint32_t    colors_used;
    uint32_t    colors_important;
    /* ColorTable */

} __attribute__ ((packed)) bmp_header_t;
  • signature[2] - 标志位 'BM'表示Windows下的格式
  • file_size - BMP文件大小
  • reserved;
  • data_offset - 文件头到数据区的位移

DIB Header

  • size : DIB头信息的字节数
  • width : width of the bitmap in pixels
  • height - height of the bitmap in pixels
  • planes : 旧设备会用到调色板的概念,现在已经用不到。置1即可
  • bit_count : number of bits per pixel,每个像素占用的位数
  • compression : 压缩方式。最常用的是BI_RGB,表示不压缩
  • image_size : 数据区的大小,单位为字节
  • x_pixels_per_m : 水平方向上每米的像素个数
  • y_pixels_per_m : 垂直方向上每米的像素个数
  • colors_used : 调色板上颜色个数
  • colors_important : 重要颜色的个数,0表示每个颜色都重要。此值常忽略

另外需要注意数据区中,每行都要4字节对齐

转载于:https://www.cnblogs.com/sammei/p/3976870.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值