当前位置: 首页 > article >正文

有压缩格式的Bitmap(BMP)图像显示调色板数据和图像数据

有压缩格式的Bitmap BMP图像显示调色板数据和图像数据

  • 参考文章
  • 一、测试代码
  • 二、测试结果
  • 三、调色板数据
  • 四、图像数据

参考文章

  • Bitmap(BMP)图像信息验证
  • Bitmap(BMP)图像信息分析主要说明带压缩的形式

一、测试代码

在这里插入图片描述


int main(int argc, char *argv[]) 
{
    u32 ColorPaletteTable[256]  = {0};
    u8 ImageColorData[5 * 1024] = {0};
    const u8 * pSrcDir = "xDemoUI\\b057_pd_delay3.bmp";
    FILE * pImgFileHandler = NULL;
    BitMapInfo_TypeDef BitMapInfo = {0};



    printf("BitMapFileHeader_TypeDef:%d\r\n", sizeof(BitMapFileHeader_TypeDef));
    printf("BitMapInfoHeader_TypeDef:%d\r\n", sizeof(BitMapInfoHeader_TypeDef));
    printf("BitMapInfo_TypeDef:%d\r\n",       sizeof(BitMapInfo_TypeDef));
    printf("\r\n\r\n");


    /* 打开文件 */
    pImgFileHandler = fopen(pSrcDir, "rb");
    if (pImgFileHandler == NULL) 
    {
        printf("Open File Error......\r\n");
        while (1); 
    }

    /* 读取Bitmap信息 */
    if (!fread(&BitMapInfo, sizeof(BitMapInfo_TypeDef), 1, pImgFileHandler)) 
    {
        printf("Read Bitmap Info Error......\r\n");
        while (1);
    }

    printf("File %s Bitmap Info:\r\n", pSrcDir);
    printf("FileType     :%X\r\n", BitMapInfo.FileHeader.FileType);
    printf("FileSize     :%d\r\n", BitMapInfo.FileHeader.FileSize);
    printf("ImgDataOffset:%d\r\n", BitMapInfo.FileHeader.ImgDataOffset);
    printf("\r\n");

    printf("InfoHeaderSize:%d\r\n", BitMapInfo.InfoHeader.InfoHeaderSize);
    printf("ImgWidth      :%d\r\n", BitMapInfo.InfoHeader.ImgWidth);
    printf("ImgHeight     :%d\r\n", BitMapInfo.InfoHeader.ImgHeight);
    printf("ColorPlanes   :%d\r\n", BitMapInfo.InfoHeader.ColorPlanes);
    printf("PixelsBits    :%d\r\n", BitMapInfo.InfoHeader.PixelsBits);
    printf("CompresType   :%d\r\n", BitMapInfo.InfoHeader.CompresType);
    printf("ImgDataSize   :%d\r\n", BitMapInfo.InfoHeader.ImgDataSize);
    printf("HorResolut    :%d\r\n", BitMapInfo.InfoHeader.HorResolut);
    printf("VerResolut    :%d\r\n", BitMapInfo.InfoHeader.VerResolut);
    printf("ColorPalette  :%d\r\n", BitMapInfo.InfoHeader.ColorPalette);
    printf("ColorImportant:%d\r\n", BitMapInfo.InfoHeader.ColorImportant);
    printf("\r\n\r\n");


    /* 设置文件指针偏移 */
    if (fseek(pImgFileHandler, sizeof(BitMapInfo_TypeDef), SEEK_SET))
    {
        printf("Set Offset Error.....1\r\n");
        while (1);
    }

    /* 读取调色板信息 */
    if (fread(ColorPaletteTable, (BitMapInfo.InfoHeader.ColorPalette * 4), 1, pImgFileHandler))
    {
        /* 显示调色板数据  */
        printf("Color Palette Table Info ==> Start:%-5d Size:%-5u Group:%u\r\n", sizeof(BitMapInfo_TypeDef), (BitMapInfo.InfoHeader.ColorPalette << 2), BitMapInfo.InfoHeader.ColorPalette);
        vShow_ColorPalette_Table(ColorPaletteTable,  BitMapInfo.InfoHeader.ColorPalette);
    }



    /* 设置文件指针偏移 */
    if (fseek(pImgFileHandler, BitMapInfo.FileHeader.ImgDataOffset, SEEK_SET))
    {
        printf("Set Offset Error.....2\r\n");
        while (1);
    }

    /* 读取图像数据 */
    if (fread(ImageColorData, BitMapInfo.InfoHeader.ImgDataSize, 1, pImgFileHandler))
    {
        /* 显示图像数据 */
        printf("Color Data Table Info ==> Start:%-5d Size:%-5u\r\n", BitMapInfo.FileHeader.ImgDataOffset, BitMapInfo.InfoHeader.ImgDataSize);
        vShow_ColorData_Table(ImageColorData, BitMapInfo.InfoHeader.ImgDataSize);
    }


    /* 关闭文件 */
    if (pImgFileHandler)
    {
        fclose(pImgFileHandler);
    }

    printf("\r\n\r\n");
    printf("Compiler Date : %s  %s\r\n", __DATE__, __TIME__);
    while(1);
    return 0;
}

二、测试结果

在这里插入图片描述

三、调色板数据


Color Palette Table Info ==> Start:54    Size:688   Group:172
-------------------------------------------Color Palette Table(ARGB)--------------------------------------------
                00        01        02        03        04        05        06        07        08        09
----------------------------------------------------------------------------------------------------------------
00000000    00FF0000  00FB0000  00F80000  00F70000  00F60000  00F50000  00F40000  00F30000  00F20000  00F10000
00000010    00EB0000  00E50000  00DF0000  00DC0000  00DB0000  00D70000  00D50000  00D30000  00D20000  00D10000
00000020    00CE0000  00C90000  00C80000  00C50000  00C40000  00C00000  00BF0000  00BE0000  00B80000  00B70000
00000030    00B60000  00B30000  00B10000  00AE0000  00AA0000  00A70000  00A40000  009F0000  009A0000  00990000
00000040    00980000  008F0000  008B0000  008A0000  00880000  00870000  00850000  00840000  00800000  00770101
00000050    00750101  00740101  00710101  006F0101  006E0101  006C0101  006A0101  00690101  00680101  00670101
00000060    00660101  00630101  005F0101  005B0101  005A0101  00530101  00510101  004B0101  00440101  00420101
00000070    00410101  003E0101  003B0101  00390101  00380101  00370101  00350101  00340101  00330101  00310101
00000080    002F0101  002D0101  002B0101  002A0101  00290101  00280101  00260101  00250101  00220101  00200101
00000090    001E0101  001C0101  001B0101  001A0101  00190101  00170101  00160101  00150101  00140101  00130101
00000100    00120101  00110101  00100101  000E0101  000D0101  000C0101  000B0101  00090101  00080101  00070101
00000110    00060101  00040101  00020101  00FFFFFF  00F6F6F6  00F3F3F3  00EDEDED  00ECECEC  00E6E6E6  00DADADA
00000120    00D9D9D9  00D6D6D6  00D0D0D0  00C0C0C0  00BEBEBE  00B8B8B8  00AFAFAF  00AEAEAE  00A9A9A9  00A5A5A5
00000130    00989898  008C8C8C  00878787  007F7F7F  007B7B7B  00767676  00757575  00737373  006E6E6E  00686868
00000140    00676767  00616161  00595959  00515151  00505050  004F4F4F  004B4B4B  00474747  00434343  00424242
00000150    00404040  003D3D3D  00333333  00323232  002D2D2D  002A2A2A  00282828  00252525  00242424  001B1B1B
00000160    00181818  00151515  000E0E0E  000D0D0D  00080808  00070707  00050505  00030303  00020202  00010101
00000170    00FFFFFF  00000000
----------------------------------------------------------------------------------------------------------------

在这里插入图片描述

四、图像数据

Color Data Table Info ==> Start:742   Size:790
------------------------Color Data Table---------------------
            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
-------------------------------------------------------------
00000000    16 A9 01 25 01 0C 04 A9 01 9C 01 9C 10 A9 00 00
00000010    16 A9 01 23 01 0A 04 A9 01 79 01 82 10 A9 00 00
00000020    16 A9 00 0E 23 0A A9 A9 A9 A2 73 91 A9 A9 A9 6D
00000030    64 70 0A A9 00 00 16 A9 00 0E 43 39 A9 A9 A9 A4
00000040    9D A4 A9 A9 A9 34 07 6F 0A A9 00 00 20 A9 00 03
00000050    69 00 26 00 0B A9 00 00 20 A9 01 2E 01 04 0C A9
00000060    00 00 20 A9 01 58 01 50 04 A9 01 87 01 86 06 A9
00000070    00 00 25 A9 00 03 8C 71 88 00 06 A9 00 00 25 A9
00000080    01 8D 01 89 07 A9 00 00 2E A9 00 00 2A A9 00 04
00000090    66 6E A9 A9 00 00 29 A9 00 05 22 00 4F A9 A9 00
000000A0    00 00 27 A9 00 07 5F 00 00 37 A9 A9 A9 00 00 00
000000B0    27 A9 00 07 5B 33 6A A9 A9 A9 A9 00 00 00 2E A9
000000C0    00 00 05 A9 01 5C 01 57 27 A9 00 00 05 A9 00 05
000000D0    2F 00 13 32 59 00 21 A9 00 03 8A 72 90 00 00 00
000000E0    05 A9 01 1D 04 00 00 03 0F 31 4E 00 09 A9 01 69
000000F0    01 67 13 A9 00 03 7B 75 98 00 00 00 05 A9 00 03
00000100    52 3A 19 00 05 00 00 03 10 29 4D 00 04 A9 00 06
00000110    46 18 05 01 11 40 14 A9 00 00 08 A9 00 03 53 35
00000120    15 00 05 00 00 04 14 2D 69 42 06 00 01 2F 13 A9
00000130    00 00 0B A9 00 09 5D 3C 17 01 00 00 00 02 03 00
00000140    07 00 01 43 12 A9 00 00 00 04 64 62 60 69 0A A9
00000150    00 04 6A 38 1F 04 09 00 01 27 0E A9 00 04 6B 60
00000160    62 64 00 00 00 04 08 00 00 28 0E A9 01 20 08 00
00000170    01 1B 0E A9 00 04 33 00 00 08 00 00 00 04 41 3E
00000180    3B 4D 0E A9 01 33 08 00 01 24 0E A9 00 04 55 3B
00000190    3E 41 00 00 12 A9 01 4B 08 00 01 3F 12 A9 00 00
000001A0    13 A9 01 30 06 00 01 21 13 A9 00 00 14 A9 00 06
000001B0    3B 06 00 00 00 2C 14 A9 00 00 00 04 A5 84 7A 9D
000001C0    11 A9 00 04 6C 45 43 63 12 A9 00 03 7F 7E A0 00
000001D0    00 00 00 04 9B 71 78 A1 27 A9 00 03 80 71 92 00
000001E0    00 00 01 A9 01 A8 2C A9 00 00 2E A9 00 00 05 A9
000001F0    01 4D 01 5A 20 A9 01 65 01 4C 05 A9 00 00 00 07
00000200    A9 A9 A9 61 16 00 48 00 20 A9 00 07 5E 00 09 51
00000210    A9 A9 A9 00 00 00 00 06 A9 A9 A9 0B 00 47 22 A9
00000220    00 06 58 0D 00 53 A9 A9 00 00 00 05 A9 A9 A9 51
00000230    67 00 25 A9 00 04 4C 66 A9 A9 00 00 2E A9 00 00
00000240    07 A9 01 99 01 8F 1C A9 01 96 01 95 07 A9 00 00
00000250    06 A9 00 03 9A 71 7D 00 1C A9 00 03 85 71 8E 00
00000260    06 A9 00 00 06 A9 01 8B 01 7C 04 A9 01 6A 01 6A
00000270    12 A9 01 6D 01 68 04 A9 01 81 01 82 06 A9 00 00
00000280    0C A9 01 1E 01 1C 12 A9 01 2B 01 0E 0C A9 00 00
00000290    0B A9 00 03 44 00 3D 00 12 A9 00 03 4F 00 36 00
000002A0    0B A9 00 00 0B A9 00 0D 12 1A A9 A9 A9 A8 A6 A8
000002B0    A9 A9 A9 54 49 00 04 A9 00 07 A6 A7 A9 A9 A9 2A
000002C0    06 00 0B A9 00 00 0B A9 00 19 4A 56 A9 A9 A9 9F
000002D0    74 94 A9 A9 A9 23 0A A9 A9 A9 A3 77 94 A9 A9 A9
000002E0    60 48 70 00 0A A9 00 00 10 A9 00 08 90 71 A0 A9
000002F0    A9 A9 23 0A 04 A9 01 76 01 83 10 A9 00 00 10 A9
00000300    01 9E 01 93 04 A9 01 25 01 0C 04 A9 01 93 01 97
00000310    10 A9 00 01 00 00
-------------------------------------------------------------

在这里插入图片描述







http://www.kler.cn/a/458922.html

相关文章:

  • UE5失真材质
  • Vue项目中生成node_modules文件夹的两种常用方法及npm优势
  • 单元测试4.0+思路总结
  • ESP32-S3遇见OpenAI:OpenAI官方发布ESP32嵌入式实时RTC SDK
  • Vue.js组件开发-使用KeepAlive缓存特定组件
  • GPU 进阶笔记(一):高性能 GPU 服务器硬件拓扑与集群组网
  • 单机部署elasticsearch集群
  • torch.save的用法
  • 机器学习中的常用特征选择方法及其应用案例
  • 【Qt】多元素控件:QListWidget、QTableWidget、QTreeWidget
  • I2C(一):存储器模式:stm32作为主机对AT24C02写读数据
  • 2024年12月28日人工智能与科技新闻速递
  • 使用 MediaDevices API 录制和下载视频教程
  • 基于Spring Boot + Vue3实现的在线预约看房管理系统源码+文档
  • 软硬件开发相关标准汇总
  • 联邦协作训练大模型的一些研究进展
  • 【LC】3159. 查询数组中元素的出现位置
  • mac docker部署jar包流程
  • 循环服务器
  • [Bert] 提取特征之后训练模型报梯度图错误
  • Effective C++ 条款42:了解 typename 的双重意义
  • 玉米中的元基因调控网络突出了功能上相关的调控相互作用。\ca.19a5.R
  • vue项目利用webpack进行优化案例
  • 小米路由器开启SSH,配置阿里云ddns,开启外网访问SSH和WEB管理界面
  • SAP-MM-物资库存调度调剂清单
  • 深入探讨C++中的互斥锁管理:`std::lock_guard`与`std::unique_lock`