• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Error

            C++博客 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

            記憶中獲取dib位圖是有順序一說的,,,今天被坑了一把確實(shí)是有一說,是和圖像的格式相關(guān)的,MSDN上這樣描述:

            A pointer to the bitmap buffer. If the bitmap is a bottom-up DIB, the pointer points near the end of the buffer. If the bitmap is a top-down DIB, the pointer points to the first byte of the buffer.

            摘錄網(wǎng)上查到的筆記:

            CImage類提供了GetBits()函數(shù)來讀取數(shù)據(jù)區(qū),GetBits()函數(shù)返回的是圖片最后一行第一個(gè)像素的地址,網(wǎng)上有人說返回指針的起始位置是不同的,有些圖片返回的是左上角像素的地址,有些是左下角像素的地址,跟圖片內(nèi)部順序有關(guān)。這里我們不必關(guān)心起始位置,只要很另外兩個(gè)函數(shù)GetPitch()和GetHeight()一起使用就可以得到圖片數(shù)據(jù)取得起始位置,定義數(shù)據(jù)區(qū)指針為BYTE* img_Data

            img_Data=(BYTE *)m_Image.GetBits()+(m_Image.GetPitch()*(m_Image.GetHeight()-1));

            這樣,img_Data就是圖片數(shù)據(jù)區(qū)的起始位置,這個(gè)公式是從codeproject里看到的,介紹的很精辟,可以從google里搜索到。其中GetHeight()函數(shù)返回圖片的高度(以像素為單位)。GetPitch()返回圖像的斜度,如果圖像的順序是從下到上(也就是GetBits()返回左上角像素的地址),這時(shí)GetPitch()返回一個(gè)負(fù)值,大小為圖像寬所占有的字節(jié)數(shù),例如24位800*600的圖片,返回值應(yīng)該是正或負(fù)的800*3。這樣用每一行的字節(jié)數(shù)乘行數(shù)就可以得到起始位置了。

             

            以上是使用CImage獲取的時(shí)候遇到的坑爹,相信直接使用位圖相關(guān)的api也是一樣,msdn描述:

            Device-Independent Bitmaps

            There are two varieties of DIBs:

            • A bottom-up DIB, in which the origin lies at the lower-left corner.
            • A top-down DIB, in which the origin lies at the upper-left corner.

            使用gdiplus的時(shí)候BitmapData也是類似:

            Stride
            INT
            Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.

             

            兩個(gè)關(guān)鍵屬性:

            GetPitch( )

            Stride

             

            還有泥馬一個(gè)被微軟坑了的壞習(xí)慣,DWORD用習(xí)慣了,調(diào)試了一天都沒看出來這兩個(gè)值我取到的是負(fù)的,,,坑啊,,,

            posted on 2013-12-30 22:26 Enic 閱讀(1086) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 從零開始寫棋牌游戲平臺(tái)
            久久国语露脸国产精品电影| 久久天天婷婷五月俺也去| 性做久久久久久免费观看| 三级三级久久三级久久 | 久久婷婷是五月综合色狠狠| 欧美麻豆久久久久久中文| 午夜精品久久久久久影视777| 久久亚洲AV成人无码软件| 久久午夜伦鲁片免费无码| 精品久久久久久99人妻| 久久久一本精品99久久精品88| 久久午夜电影网| 久久精品青青草原伊人| 久久精品草草草| 精品无码久久久久国产动漫3d| 久久久精品国产sm调教网站| 精品熟女少妇aⅴ免费久久| 777午夜精品久久av蜜臀| 久久久久久久91精品免费观看 | 久久久久女教师免费一区| 国产精品久久99| 看久久久久久a级毛片| 成人亚洲欧美久久久久| 精品久久一区二区| 久久人人爽人人人人爽AV| 久久精品成人免费网站| 久久精品国产精品亚洲精品| 精品无码人妻久久久久久| 久久超碰97人人做人人爱| 少妇人妻综合久久中文字幕| 欧美精品丝袜久久久中文字幕 | 亚洲国产精品无码久久98| 久久国产欧美日韩精品免费| 国产高清美女一级a毛片久久w| 国产美女久久精品香蕉69| 久久综合九色综合精品| 人妻精品久久久久中文字幕69 | 久久久久亚洲爆乳少妇无| 人人狠狠综合久久亚洲88| 99久久国产综合精品麻豆| 久久99热只有频精品8|