亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

設備無關位圖DIB的顯示

系統 2759 0
下面是以自定義的WINAPI方式的函數
HGLOBAL WINAPI ReadDIBFile(CFile &file)
{
BITMAPFILEHEADER header;
DWORD dwbitsize;
HGLOBAL hdib;
LPSTR pdib;
dwbitsize=file.getlength();
file.read(&header,sizeof(header));//讀入header指向的內存
hdib=GlobalAlloc(GMEM_MOVEABLE,dwBitSize);
pdib=(char*)GlobalLock(hdib);
file.readhuge(pdib,dwbitsize-sizeof(header));//將位圖文件數據寫入鎖定內存塊
// BITMAPINFO結構定義,至此,先讀入header指向的內存(BITMAPINFOHEADER),
// 接著再寫入位圖文件數據(RGBQUAD),符合BITMAPINFO結構。
//
//The BITMAPINFO structure defines the dimensionsand
//color information for a DIB.
      //typedef struct tagBITMAPINFO { 
      
         // BITMAPINFOHEADER 
      
      
        
          bmiHeader
        
      
      
        ;  // RGBQUAD          
      
      
        
          bmiColors
        
      
      
        [1];
      
       //} BITMAPINFO, *PBITMAPINFO; 
    
//
//
Globalunlock(hdib);
return hdib;
}
調用上面的自定義API顯示
HGLOBAL h_mem;
LPSTR*lpMEM;
h_mem=::ReadDIBFile(bmpfile);
lpMEM=(LPSTR)globallock(h_mem);
bitblt(1,1,20,20,0,0,(LPBITMAPINFO)lpMEM,SRCCOPY)
關于GlobalLock
Memory Management
GlobalLock

Locks a global memory object and returns a pointer to the firstbyte of the object's memory block.

Note Theglobal functions are slower than other memory management functionsand do not provide as many features. Therefore, new applicationsshould use the heapfunctions . However, the global functions are still used withDDE and the clipboard functions.

            LPVOID GlobalLock(  HGLOBAL hMem);
          

Parameters

hMem
[in] A handle to the global memory object. This handle isreturned by either the GlobalAlloc or GlobalReAlloc function.

Return Values

If the function succeeds, the return value is a pointer to thefirst byte of the memory block.

If the function fails, the return value is NULL. To get extendederror information, call GetLastError .

Remarks

The internal data structures for each memory object include alock count that is initially zero. For movable memory objects, GlobalLock increments the count by one, and the GlobalUnlock function decrements the count by one. For eachcall that a process makes to GlobalLock for an object, itmust eventually call GlobalUnlock . Locked memory will not bemoved or discarded, unless the memory object is reallocated byusing the GlobalReAlloc function. The memory block of a locked memoryobject remains locked until its lock count is decremented to zero,at which time it can be moved or discarded.

Memory objects allocated with GMEM_FIXED always have a lockcount of zero. For these objects, the value of the returned pointeris equal to the value of the specified handle.

If the specified memory block has been discarded or if thememory block has a zero-byte size, this function returns NULL.

Discarded objects always have a lock count of zero.

BITMAPINFO結構

BITMAPINFO

The BITMAPINFO structure defines the dimensions and colorinformation for a DIB.

        typedef struct tagBITMAPINFO {   BITMAPINFOHEADER 
        
          
            bmiHeader
          
        
        ;   RGBQUAD          
        
          
            bmiColors
          
        
        [1]; } BITMAPINFO, *PBITMAPINFO; 
      

Members

bmiHeader
Specifies a BITMAPINFOHEADER structure that contains information about the dimensions of colorformat.

.

bmiColors
The bmiColors member contains one of the following:
  • An array of RGBQUAD .The elements of the array that make up the color table.
  • An array of 16-bit unsigned integers that specifies indexesinto the currently realized logical palette. This use of bmiColors is allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logicalpalette, they must also call the following bitmap functions:

    CreateDIBitmap

    CreateDIBPatternBrush

    CreateDIBSection

    The i Usage parameter of CreateDIBSection must beset to DIB_PAL_COLORS.

The number of entries in the array depends on the values of the biBitCount and biClrUsed members of the BITMAPINFOHEADER structure.

The colors in the bmiColors table appear in order ofimportance. For more information, see the Remarks section.

Remarks

A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions and colors of the bitmap, andan array of bytes defining the pixels of the bitmap. The bits inthe array are packed together, but each scan line must be paddedwith zeroes to end on a LONG data-type boundary. If theheight of the bitmap is positive, the bitmap is a bottom-up DIB andits origin is the lower-left corner. If the height is negative, thebitmap is a top-down DIB and its origin is the upper leftcorner.

A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. Packed bitmaps are referenced by a singlepointer. For packed bitmaps, the biClrUsed member must beset to an even number when using the DIB_PAL_COLORS mode so thatthe DIB bitmap array starts on a DWORD boundary.

Note The bmiColors member should not contain palette indexes if thebitmap is to be stored in a file or transferred to anotherapplication.

Unless the application has exclusive use andcontrol of the bitmap, the bitmap color table should containexplicit RGB values.

設備無關位圖DIB的顯示


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日本午夜www高清视频 | 欧美成人另类bbw | 黄色毛片免费在线观看 | 激情五月综合综合久久69 | 大香伊人久久 | 欧美日韩免费 | 国产欧美另类第一页 | 最新香蕉97超级碰碰碰碰碰久 | 亚洲一区中文字幕在线 | 香蕉18xxoo欧美夜视频 | 欧美一区二区影院 | 久久久久久久久久爱 | 最近中文字幕无吗免费视频 | 亚洲欧美另类久久久精品能播放的 | 欧美一区精品二区三区 | 亚洲精品欧美精品一区二区 | 简单视频在线播放jdav | 99精品视频在线成人精彩视频 | 亚洲精品视频在线看 | 伊人激情久久综合中文字幕 | 91精品国产综合久久久久 | 成人美女免费网站视频 | 久久艹在线 | 日本一区二区三区不卡在线视频 | 国产91小视频在线观看 | 久久精品国产一区二区三区不卡 | 五月狠狠亚洲小说专区 | 美女黄www视频 | 国产成人禁片免费观看视频 | 97久久久久 | 国产精品视频一区二区三区经 | 玖玖视频精品 | 欧美久久网| 亚洲视频第二页 | 久久99中文字幕久久 | 日日天日日夜日日摸 | 91在线网址 | 久久久99精品免费观看 | 国产成人8x视频一区二区 | 免费看人做人爱视频拍拍拍 | 日韩不卡一区二区三区 |