本帖最后由 lxchgs 于 2014-04-07 10:30:35 编辑

解决方案 »

  1.   

    int pitch=width+width%2;//??????
    bmp 宽度必须是 4 字节 的整数倍 , 不够的要补齐.
    你这里:
    width%2 =0 或 1;
    width奇数+1=偶数
    width偶数+0=偶数这样 width 一定是2的倍数,也就是 一定是4的倍数.[(i*pitch+j)*2];//?????
    就是计算 地址
    i*pitch  高*宽; +当前宽;*2 是16位
      

  2.   

    好像有问题, 2,4,6,8,10 ;其中 6 , 10 就不是.
    我记不清楚了 好像 NT 是要求 WORD , 通常 要求4的倍数.
      

  3.   


    width=13,按它这个写法pitch=width+width%2 =14,14就不是4的倍数
      

  4.   

    我记得正确的写法是
    (width+4) & 0xfffffffC
      

  5.   

    if(info.bmiHeader.biBitCount==1)
       {
    int pitch=width+width%2;
    for(int i=0;i<height;i++)
    {
    for(int j=0;j<width;j++)
    {
    short int a = (short int)buffer[(i*pitch+j)/8];//
    if(a != 0)
    {
    pbMap[(height - i -1)*width+ j] = 1;//这里应该怎么设置
    }
    }
    }

    }请问下,如果处理二值图pbMap[(height - i -1)*width+ j] = 1;这里应该怎么设置?
      

  6.   

                    BYTE a = (short int)buffer[(i*pitch+j)/8];//
                    if(a != 0)
                    {
                        pbMap[(height - i -1)*width+ j] = 1;// 8位 都==1?
                    }
      

  7.   

    pbMap就是用A*来寻路的!应该怎么设置呢?
      

  8.   

    不知道从 buffer  转存到 pbMap 目的何在?
      

  9.   

     就是根据二值位图0 1存放到pbMap,然后根据pbMap中点阵来使用A星算法
      

  10.   

    //                if(a != 0)
                    {
                        pbMap[i*pitch+j]= a ;//这里应该怎么设置
                    }
      

  11.   

    建议使用
    HBITMAP hBmp = CreateDIBSection(hMemDC, &bmpinfo, DIB_RGB_COLORS, 0, NULL, 0);
    // second GetDIBits call to make DIB
    LPBYTE lpImage = (LPBYTE) new char[m_dwSizeImage];
    VERIFY(::GetDIBits(pDC->GetSafeHdc(), hBitmap, 0, (UINT) lpBMIH->biHeight,
         lpImage, (LPBITMAPINFO) lpBMIH, DIB_RGB_COLORS));不要那个pbMap