BMP文件格式及相应结构体

/**

  • @file name: main.c
  • @brief BMP文件结构体
  • @author 1810866453@163.com
  • @date 2024/05/12
  • @version 1.0 :版本
  • @property :属性介绍
  • @note 补充 注意 说明
  • CopyRight (c) 2023-2024 RISE_AND_GRIND@163.com All Right Reseverd
    */
// 文件信息结构体
typedef struct tag_bitmap_file_header
{
    unsigned short file_type; // 文件标识,为字母ASCII码“BM”
    unsigned int file_size;   // 位图文件大小,以字节为单位
    unsigned short reserved1; // 位图文件保留字,必须为0
    unsigned short reserved2; // 位图文件保留字,必须为0
    unsigned int offset_bits; // 文件开始到位图数据开始之间的偏移量字节
} __attribute__((packed)) bitmap_file_header;

// 位图信息结构体
typedef struct tag_bitmap_info_header
{
    unsigned int bitmap_info_size; // 图像描述信息快的大小,常为28H
    int bitmap_width;              // 图像宽度
    int bitmap_height;             // 图像高度
    unsigned short planes;         // 图像的plane总数(恒为1)
    unsigned short image_depth;    // 记录颜色的位数取值1(双色),4,6,24,,3
    unsigned int compression;      // 数据压缩方式(0:不压缩;1:8位压缩;2:4位压缩
    unsigned int image_size;       // 图像区数据的大小,必须是4的倍数
    int x_pels_permeter;           // 水平每米有多少像素,在设备无关位图中,填写00H
    int y_pels_permeter;           // 垂直每米有多少像素,在设备无关位图中,填写00H
    unsigned int color_used;       // 此图像所有的颜色数,不用,固定为0
    unsigned int color_important;  // 重要颜色数,不用,固定为0
} __attribute__((packed)) bitmap_info_header;

// 调色板信息结构体
typedef struct tag_bitmap_palette
{
    unsigned char blue;
    unsigned char green;
    unsigned char red;
    unsigned char reserved;
} __attribute__((packed)) bitmap_palette;
posted @   Zeratul$$$  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示