• 24位位图格式解析


    每一行的图素数等于该结构的bcWidth字段。每一行从最左边的图素开始,直到图像的右边。分别对应的B,G,R像素。每个像素占8位, 每列的宽度为bcWidth,必须为4的倍数,不足的用零填充。

    下面是读取二十四位位图的关键代码:

    代码
     1 BITMAPFILEHEADER * pbmfh ;
     2 BITMAPINFO       * pbmi ;
     3 BYTE             * pBits ;
     4 pbmfh = DibLoadImage (szFileName) ;
     5 pbmi  = (BITMAPINFO *) (pbmfh + 1) ;
     6 pBits = (BYTE *) pbmfh + pbmfh->bfOffBits ;
     7 for( i=0; i < 1024; i++)
     8 {
     9     pPrintBlock[i] =  (char*)malloc(216);
    10     memset(pPrintBlock[i], 0216);
    11 }
    12 
    13 for(h = 0; h <  pbmi->bmiHeader.biHeight; h++)
    14 {
    15     for(w = 0; w <  pbmi->bmiHeader.biWidth; w++)
    16     {
    17         b1 = *pBits;          //B
    18         b2 = *(pBits+1);      //G
    19         b3 = *(pBits+2);      //R
    20         if( (int)b1 != 255 && (int)b2 != 255 && (int)b3 != 255)
    21         {
    22             index = w / 8;
    23             index = 1 << (w%8);
    24             index = pPrintBlock[h][w / 8| ( 1 << (w%8) );
    25             pPrintBlock[h][w / 8= pPrintBlock[h][w / 8| ( 1 << (w%8) );
    26         }    
    27         pBits += 3;
    28 
    29     }
    30     if(pbmi->bmiHeader.biWidth *3 % 4 != 0)
    31     {
    32         pBits += ( 4 - pbmi->bmiHeader.biWidth*3 % 4);
    33     }
    34 }
    35 
  • 相关阅读:
    APMServ5.2.6 无法启动Apache的一个问题
    【转】流媒体技术笔记(视频编码相关)
    用APMServ一键快速搭建Apache+PHP+MySQL+Nginx+Memcached+ASP运行平台
    java swing 基础
    python class 类
    python 经验
    python 导入(转)
    kernel ipv4/ip_output.c
    python+正则表达式(转)
    Eclipse中如何快速添加、删除jar包
  • 原文地址:https://www.cnblogs.com/frischzenger/p/1805171.html
Copyright © 2020-2023  润新知