亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dibapi.cpp

?? 圖像霍夫曼編碼顯示 目前只支持256色圖像的顯示
?? CPP
?? 第 1 頁 / 共 5 頁
字號(hào):
//********************************************************************** 
// 
//  AIBAPI.CPP
// 
//  Source file for Device-Independent Bitmap (DIB) API. 
// 
//********************************************************************** 
 
#define     STRICT      // enable strict type checking 
 
#include "stdafx.h"
#include <string.h> 
#include <stdio.h> 
#include <math.h> 
#include <io.h> 
#include <direct.h> 
#include <stdlib.h> 
#include <assert.h> 
#include <windows.h> 
#include <windowsx.h> 
#include <mmsystem.h> 
#include "dibapi.h" 

 
/************************************************************************* 
 * 
 * CreateDIB() 
 * 
 * Parameters: 
 * 
 * DWORD dwWidth    - Width for new bitmap, in pixels 
 * DWORD dwHeight   - Height for new bitmap  
 * WORD  wBitCount  - Bit Count for new DIB (1, 4, 8, or 24) 
 * 
 * Return Value: 
 * 
 * HDIB             - Handle to new DIB 
 * 
 * Description: 
 * 
 * This function allocates memory for and initializes a new DIB by 
 * filling in the BITMAPINFOHEADER, allocating memory for the color 
 * table, and allocating memory for the bitmap bits.  As with all 
 * HDIBs, the header, colortable and bits are all in one contiguous 
 * memory block.  This function is similar to the CreateBitmap()  
 * Windows API. 
 * 
 * The colortable and bitmap bits are left uninitialized (zeroed) in the 
 * returned HDIB. 
 * 
 * 
 ************************************************************************/ 
HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount) 
{ 
    BITMAPINFOHEADER    bi;             // bitmap header 
    LPBITMAPINFOHEADER  lpbi;           // pointer to BITMAPINFOHEADER 
    DWORD               dwLen;          // size of memory block 
    HDIB                hDIB; 
    DWORD               dwBytesPerLine; // Number of bytes per scanline 
 
 
    // Make sure bits per pixel is valid 
 
    if (wBitCount <= 1) 
        wBitCount = 1; 
    else if (wBitCount <= 4) 
        wBitCount = 4; 
    else if (wBitCount <= 8) 
        wBitCount = 8; 
    else if (wBitCount <= 24) 
        wBitCount = 24; 
    else 
        wBitCount = 4;  // set default value to 4 if parameter is bogus 
 
    // initialize BITMAPINFOHEADER 
 
    bi.biSize = sizeof(BITMAPINFOHEADER); 
    bi.biWidth = dwWidth;         // fill in width from parameter 
    bi.biHeight = dwHeight;       // fill in height from parameter 
    bi.biPlanes = 1;              // must be 1 
    bi.biBitCount = wBitCount;    // from parameter 
    bi.biCompression = BI_RGB;     
    bi.biSizeImage = 0;           // 0's here mean "default" 
    bi.biXPelsPerMeter = 0; 
    bi.biYPelsPerMeter = 0; 
    bi.biClrUsed = 0; 
    bi.biClrImportant = 0; 
 
    // calculate size of memory block required to store the DIB.  This 
    // block should be big enough to hold the BITMAPINFOHEADER, the color 
    // table, and the bits 
 
    dwBytesPerLine = WIDTHBYTES(wBitCount * dwWidth); 
    dwLen = bi.biSize + PaletteSize((LPBYTE)&bi) + (dwBytesPerLine * dwHeight); 
 
    // alloc memory block to store our bitmap 
 
    hDIB = GlobalAlloc(GHND, dwLen); 
 
    // major bummer if we couldn't get memory block 
 
    if (!hDIB) 
        return NULL; 
 
    // lock memory and get pointer to it 
 
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB); 
 
    // use our bitmap info structure to fill in first part of 
    // our DIB with the BITMAPINFOHEADER 
 
    *lpbi = bi; 
 
    // Since we don't know what the colortable and bits should contain, 
    // just leave these blank.  Unlock the DIB and return the HDIB. 
 
    GlobalUnlock(hDIB); 
 
    //return handle to the DIB 
 
    return hDIB; 
} 
 
/************************************************************************* 
 * 
 * CreateDefaultDIB() 
 * 
 * Parameters: 
 * 
 * DWORD dwWidth    - Width for new bitmap, in pixels 
 * DWORD dwHeight   - Height for new bitmap  
  * 
 * Return Value: 
 * 
 * HDIB             - Handle to new DIB 
 * 
 * Description: 
 * 
 * This function allocates memory for and initializes a new DIB by 
 * filling in the BITMAPINFOHEADER, allocating memory for the color 
 * table, and allocating memory for the bitmap bits.  As with all 
 * HDIBs, the header, colortable and bits are all in one contiguous 
 * memory block.  This function is similar to the CreateBitmap()  
 * Windows API. 
 * 
 * The colortable is initialized with system palette, but bitmap bits
 * are left uninitialized (zeroed) in the returned HDIB. 
 * 
 * 
 ************************************************************************/ 
HDIB CreateDefaultDIB(DWORD dwWidth, DWORD dwHeight) 
{ 
	// Get DC
    HDC hDC = GetDC(NULL); 
    if (!hDC) 
        return NULL; 

	// DC bts/pixel
	int nDeviceBitsPixel = GetDeviceCaps(hDC, BITSPIXEL);

	// create DIB according to DC
	HDIB hDIB = CreateDIB(dwWidth, dwHeight, nDeviceBitsPixel);

	// DIB buffer
	LPBITMAPINFO lpbmi = (LPBITMAPINFO)GlobalLock(hDIB);
    LPBYTE lpDIBBits = FindDIBBits((LPBYTE)lpbmi); 
    DWORD dwBitsSize = lpbmi->bmiHeader.biHeight * BytesPerLine((LPBYTE)&(lpbmi->bmiHeader)); 

	// set DIB color to White
	for (DWORD l=0; l<dwBitsSize; ++l)
		lpDIBBits[l] = 0xff;

	// if no palette, return DIB handle
	if (nDeviceBitsPixel > 8)
	{
		GlobalUnlock(hDIB);
	    ReleaseDC(NULL, hDC); 
		return hDIB;
	}

	// if there is palette, set system palette to DIB

	// colors in system palette
    int nColors = PalEntriesOnDevice(hDC);   // Number of palette entries 
  
    // Copy the current system palette into our logical palette 
	PALETTEENTRY pe[256];
    GetSystemPaletteEntries(hDC, 0, nColors, pe); 

	// set color table
	for (int i=0; i<nColors; ++i)
	{
		lpbmi->bmiColors[i].rgbRed = pe[i].peRed;
		lpbmi->bmiColors[i].rgbGreen = pe[i].peGreen;
		lpbmi->bmiColors[i].rgbBlue = pe[i].peBlue;
		lpbmi->bmiColors[i].rgbReserved = 0;
	}

    // clean up 
	GlobalUnlock(hDIB);
    ReleaseDC(NULL, hDC); 

	return hDIB;
}
/************************************************************************* 
 * 
 * DestroyDIB () 
 * 
 * Purpose:  Frees memory associated with a DIB 
 * 
 * Returns:  none 
 * 
 *************************************************************************/ 
void DestroyDIB(HDIB hDib) 
{ 
    GlobalFree(hDib); 
} 
 
/************************************************************************* 
 * 
 * Function:  ReadDIBFile (int) 
 * 
 *  Purpose:  Reads in the specified DIB file into a global chunk of 
 *            memory. 
 * 
 *  Returns:  A handle to a dib (hDIB) if successful. 
 *            NULL if an error occurs. 
 * 
 * Comments:  BITMAPFILEHEADER is stripped off of the DIB.  Everything 
 *            from the end of the BITMAPFILEHEADER structure on is 
 *            returned in the global memory handle. 
 * 
 * 
 * NOTE: The DIB API were not written to handle OS/2 DIBs, so this 
 * function will reject any file that is not a Windows DIB. 
 * 
 *************************************************************************/ 
HANDLE ReadDIBFile(HANDLE hFile) 
{ 
    BITMAPFILEHEADER    bmfHeader; 
    DWORD               dwBitsSize; 
    UINT                nNumColors;   // Number of colors in table 
    HANDLE              hDIB;         
    HANDLE              hDIBtmp;      // Used for GlobalRealloc() //MPB 
    LPBITMAPINFOHEADER  lpbi; 
    DWORD               offBits; 
    DWORD               dwRead; 
 
    // get length of DIB in bytes for use when reading 
 
    dwBitsSize = GetFileSize(hFile, NULL); 
 
    // Allocate memory for header & color table. We'll enlarge this 
    // memory as needed. 
 
    hDIB = GlobalAlloc(GMEM_MOVEABLE, (DWORD)(sizeof(BITMAPINFOHEADER) + 
            256 * sizeof(RGBQUAD))); 
 
    if (!hDIB) 
        return NULL; 
 
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB); 
 
    if (!lpbi)  
    { 
        GlobalFree(hDIB); 
        return NULL; 
    } 
 
    // read the BITMAPFILEHEADER from our file 
 
    if (!ReadFile(hFile, (LPBYTE)&bmfHeader, sizeof (BITMAPFILEHEADER), 
            &dwRead, NULL)) 
        goto ErrExit; 
 
    if (sizeof (BITMAPFILEHEADER) != dwRead) 
        goto ErrExit; 
 
    if (bmfHeader.bfType != 0x4d42)  // 'BM' 
        goto ErrExit; 
 
    // read the BITMAPINFOHEADER 
 
    if (!ReadFile(hFile, (LPBYTE)lpbi, sizeof(BITMAPINFOHEADER), &dwRead, 
            NULL)) 
        goto ErrExit; 
 
    if (sizeof(BITMAPINFOHEADER) != dwRead) 
        goto ErrExit; 
 
    // Check to see that it's a Windows DIB -- an OS/2 DIB would cause 
    // strange problems with the rest of the DIB API since the fields 
    // in the header are different and the color table entries are 
    // smaller. 
    // 
    // If it's not a Windows DIB (e.g. if biSize is wrong), return NULL. 
 
    if (lpbi->biSize == sizeof(BITMAPCOREHEADER)) 
        goto ErrExit; 
 
    // Now determine the size of the color table and read it.  Since the 
    // bitmap bits are offset in the file by bfOffBits, we need to do some 
    // special processing here to make sure the bits directly follow 
    // the color table (because that's the format we are susposed to pass 
    // back) 
 
    if (!(nNumColors = (UINT)lpbi->biClrUsed)) 
    { 
        // no color table for 24-bit, default size otherwise 
 
        if (lpbi->biBitCount != 24) 
            nNumColors = 1 << lpbi->biBitCount; // standard size table 
    } 
 
    // fill in some default values if they are zero 
 
    if (lpbi->biClrUsed == 0) 
        lpbi->biClrUsed = nNumColors; 
 
    if (lpbi->biSizeImage == 0) 
    { 
        lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 
                31) & ~31) >> 3) * lpbi->biHeight; 
    } 
 
    // get a proper-sized buffer for header, color table and bits 
 
    GlobalUnlock(hDIB); 
    hDIBtmp = GlobalReAlloc(hDIB, lpbi->biSize + nNumColors * 
            sizeof(RGBQUAD) + lpbi->biSizeImage, 0); 
 
    if (!hDIBtmp) // can't resize buffer for loading 
        goto ErrExitNoUnlock; //MPB 
    else 
        hDIB = hDIBtmp; 
 
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB); 
 
    // read the color table 
 
    ReadFile (hFile, (LPBYTE)(lpbi) + lpbi->biSize, 
            nNumColors * sizeof(RGBQUAD), &dwRead, NULL); 
 
    // offset to the bits from start of DIB header 
 
    offBits = lpbi->biSize + nNumColors * sizeof(RGBQUAD); 
 
    // If the bfOffBits field is non-zero, then the bits might *not* be 
    // directly following the color table in the file.  Use the value in 
    // bfOffBits to seek the bits. 
 
    if (bmfHeader.bfOffBits != 0L) 
        SetFilePointer(hFile, bmfHeader.bfOffBits, NULL, FILE_BEGIN); 
 
    if (ReadFile(hFile, (LPBYTE)lpbi + offBits, lpbi->biSizeImage, &dwRead, 
            NULL)) 
        goto OKExit; 
 
ErrExit: 
    GlobalUnlock(hDIB);     
 
ErrExitNoUnlock:     
    GlobalFree(hDIB); 
    return NULL; 
 
OKExit: 
    GlobalUnlock(hDIB); 
    return hDIB; 
} 

/************************************************************************* 
 * 
 * LoadDIB() 
 * 
 * Loads the specified DIB from a file, allocates memory for it, 
 * and reads the disk file into the memory. 
 * 
 * 
 * Parameters: 
 * 
 * LPCTSTR lpFileName - specifies the file to load a DIB from 
 * 
 * Returns: A handle to a DIB, or NULL if unsuccessful. 
 * 
 * NOTE: The DIB API were not written to handle OS/2 DIBs; This 
 * function will reject any file that is not a Windows DIB. 
 * 
 *************************************************************************/ 
HDIB LoadDIB(LPCTSTR lpFileName) 
{ 
    HDIB        hDIB; 
    HANDLE      hFile; 
 
    // Set the cursor to a hourglass, in case the loading operation 
    // takes more than a sec, the user will know what's going on. 
 
    SetCursor(LoadCursor(NULL, IDC_WAIT)); 
 
    if ((hFile = CreateFile(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, 
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 
            NULL)) != INVALID_HANDLE_VALUE) 
    { 
        hDIB = ReadDIBFile(hFile); 
        CloseHandle(hFile); 
        SetCursor(LoadCursor(NULL, IDC_ARROW)); 
        return hDIB; 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产三级| 午夜电影一区二区三区| 9人人澡人人爽人人精品| 亚洲精品国产精华液| 这里是久久伊人| 成人综合在线观看| 亚洲美女精品一区| 精品成人一区二区| 91美女视频网站| 日韩专区中文字幕一区二区| 欧美大片在线观看| 97se亚洲国产综合自在线观| 三级精品在线观看| 国产精品女主播av| 91麻豆精品91久久久久同性| 国产激情视频一区二区三区欧美 | 国产精品自拍一区| 亚洲欧美电影院| 欧美成人一区二区三区片免费 | 日本伊人精品一区二区三区观看方式| 日韩一区二区三区视频在线观看| 成人福利在线看| 日韩电影在线免费看| 中文字幕一区二区三区四区 | 色婷婷综合视频在线观看| 日本不卡123| 久久午夜国产精品| 欧美一a一片一级一片| 国产成人精品免费视频网站| 五月婷婷色综合| 日韩一区在线免费观看| www日韩大片| 欧美丰满一区二区免费视频| 不卡的电影网站| 精品在线一区二区| 亚洲影视资源网| 国产精品成人在线观看| 久久这里只有精品视频网| 91色.com| 99久久亚洲一区二区三区青草| 国产一区欧美一区| 亚洲成人777| 亚洲免费在线视频一区 二区| 久久综合久久久久88| 欧美美女直播网站| 精品视频资源站| 国产iv一区二区三区| 美女高潮久久久| 亚洲1区2区3区4区| 最新国产の精品合集bt伙计| 久久久久久夜精品精品免费| 欧美一区二区三区色| 欧美天堂亚洲电影院在线播放| 97se亚洲国产综合自在线| 国产一区二区三区不卡在线观看 | 欧美xxx久久| 91久久国产最好的精华液| 日本韩国欧美在线| 欧美怡红院视频| 69堂亚洲精品首页| 日韩欧美国产高清| 久久久久国产精品人| 亚洲国产精品传媒在线观看| 中文字幕一区二区视频| 亚洲一区二区三区四区中文字幕| 调教+趴+乳夹+国产+精品| 麻豆成人91精品二区三区| 国产成人精品免费看| 色噜噜狠狠一区二区三区果冻| 欧美日本在线一区| 久久综合九色综合久久久精品综合| 国产日韩精品一区二区三区| 中文字幕在线免费不卡| 一区二区不卡在线播放| 精品亚洲国内自在自线福利| 99re这里只有精品6| 欧美日本国产视频| 国产欧美精品国产国产专区 | 亚洲精品国产一区二区精华液 | 成人av片在线观看| 欧美日韩国产免费一区二区| 久久一区二区视频| 亚洲一区二区三区精品在线| 久久成人免费网| 99re这里只有精品视频首页| 欧美一区二区视频在线观看2022| 久久久久国产免费免费 | 天堂精品中文字幕在线| 青青青爽久久午夜综合久久午夜| 精品一区二区三区视频| 粉嫩aⅴ一区二区三区四区| 91免费国产在线| 精品精品国产高清a毛片牛牛| 亚洲欧洲成人精品av97| 亚洲免费视频成人| 日本va欧美va精品| 欧洲生活片亚洲生活在线观看| 91免费看视频| 91精品国产高清一区二区三区 | 91福利国产精品| 精品国产一区二区精华| 亚洲综合久久av| 不卡的电影网站| 精品88久久久久88久久久| 亚洲图片有声小说| 成人a区在线观看| 日韩午夜在线影院| 亚洲综合免费观看高清完整版| 国产精品自拍毛片| 日韩三级.com| 亚洲一区二区三区四区不卡 | 欧美性感一类影片在线播放| 国产日韩成人精品| 久久er精品视频| 欧美三级视频在线播放| 国产精品久久久久久久久免费相片 | 日韩一区二区三区av| 亚洲综合在线第一页| 国产成人精品一区二区三区四区| 正在播放亚洲一区| 亚洲一区欧美一区| 96av麻豆蜜桃一区二区| 国产欧美日韩亚州综合| 精一区二区三区| 欧美一卡二卡三卡四卡| 亚洲自拍欧美精品| 色猫猫国产区一区二在线视频| 中文字幕精品一区二区三区精品| 日韩中文字幕区一区有砖一区 | 国产高清无密码一区二区三区| 91精品国产高清一区二区三区蜜臀| 亚洲一区在线看| 在线观看免费亚洲| 亚洲精品视频自拍| 91在线观看成人| 国产欧美日韩不卡免费| 国产精品资源站在线| 久久精品一区四区| 国产一区二区三区| 久久久99久久| 国产福利电影一区二区三区| 精品国产sm最大网站| 日本aⅴ精品一区二区三区| 欧美日产在线观看| 丝袜美腿亚洲综合| 欧美日韩高清在线播放| 日日摸夜夜添夜夜添国产精品| 欧美日本一道本| 热久久免费视频| 欧美一区二区在线免费播放 | 亚洲综合男人的天堂| 欧美视频在线观看一区二区| 亚洲va国产天堂va久久en| 欧美群妇大交群中文字幕| 日本不卡一区二区| 欧美成人a在线| 国产成人免费在线| 亚洲视频一二三| 欧美亚洲一区二区三区四区| 亚洲3atv精品一区二区三区| 欧美一区二区三区免费视频| 久久66热re国产| 国产欧美日韩亚州综合| 色综合天天视频在线观看| 亚洲综合免费观看高清在线观看| 欧美老女人在线| 狠狠色狠狠色综合| 国产精品日韩成人| 欧美亚洲国产一区二区三区va| 日韩中文字幕一区二区三区| 久久综合国产精品| 97国产一区二区| 日产国产高清一区二区三区| wwww国产精品欧美| 色综合久久综合网97色综合| 日韩成人dvd| 国产精品日韩成人| 欧美日韩国产一级| 国产91色综合久久免费分享| 日韩理论片在线| 欧美一区二区三区男人的天堂| 高清久久久久久| 天天操天天干天天综合网| 久久综合久久久久88| 日本精品一级二级| 精品一区二区免费看| 亚洲精品综合在线| 日韩精品影音先锋| 一本色道久久综合亚洲精品按摩| 日本午夜精品一区二区三区电影| 国产精品网曝门| 日韩免费在线观看| 91麻豆国产自产在线观看| 美女被吸乳得到大胸91| 亚洲视频1区2区| 精品成a人在线观看| 欧美亚洲日本国产| 成人综合婷婷国产精品久久| 亚洲国产毛片aaaaa无费看| 精品成人私密视频|