#include"stdio.h"
#include"stdlib.h"
#include "readBmpImage/readBmpImage.h"
#include<imglib.h>
#include<vlib.h>
#include "uHead.h"

#include <src/IMG_sobel_3x3_8/c66/IMG_sobel_3x3_8.c>

typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;

#pragma pack(1)               /* 取消字节对齐 */

typedef struct {            /* bmp图片文件头信息封装 */
    /* 位图文件头 */
    u8  bit_file_type[2];    /* 位图文件类型:'BM'->0x4d42 */
    u32 file_size;              /* 整个文件大小 */
    u16 reserved1;              /* 保留 */
    u16 reserved2;              /* 保留 */
    u32 offset;                  /* 文件头到位图数据之间的偏移量 */

    /* 位图信息头 */
    u32 head_size;            /* 位图信息头长度 */
    u32 width;                  /* 位图宽度 */
    u32 height;                  /* 位图高度 */
    u16 bit_planes;              /* 位图位面数 */
    u16 bits_per_pixel;     /* 每个像素的位数 */
    u32 compression;        /* 压缩说明 */
    u32 image_size;            /* 位图数据大小 */
    u32 h_res;                /* 水平分辨率 */
    u32 v_res;                /* 垂直分辨率 */
    u32 color_palette;        /* 位图使用的颜色索引数 */
    u32 vip_color;            /* 重要的颜色索引数目 */

}bmp_head_t;

#pragma pack()     /* 恢复字节对齐 */

int main(void)
{
    FILE* fd;

    /* 文件打开 */
    if((fd = fopen("20170507170040090.bmp", "rb")) == NULL)
    {
        fprintf(stderr, "file cannot open ");
        exit(1);
    }

    /* 获取bmp文件头消息 */
    bmp_head_t header;
    fread(&header,1, sizeof(header),fd);

    /* 打印bmp图片信息 */
    printf("with = %d\n", header.width);
    printf("height = %d\n", header.height);
    printf("bits_per_pixel = %hd\n", header.bits_per_pixel);
    printf("file size = %d\n", header.file_size);

    return 0;
}
DSP读取BMP头信息

相关文章: