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

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

?? dibapi.cpp

?? 《精通 vc++ 圖像編程》的源代碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
//********************************************************************** 
// 
//  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
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女一区二区| 久久av资源网| 久久久久久一级片| 日韩一级二级三级| 欧美日韩一区二区三区在线看| 国产高清一区日本| 看片网站欧美日韩| 首页欧美精品中文字幕| 亚洲婷婷综合色高清在线| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 日本不卡在线视频| 一区二区三区av电影| 国产精品福利一区| 久久日韩粉嫩一区二区三区| 91精品国产综合久久久久久漫画| 99国产精品国产精品久久| 国产精品一区2区| 精品一二三四区| 欧美aaaaaa午夜精品| 日韩精品电影一区亚洲| 亚洲图片有声小说| 香蕉成人伊视频在线观看| 亚洲午夜激情av| 日本成人在线一区| 久久国产视频网| 韩日av一区二区| 国产乱码一区二区三区| 韩国av一区二区三区在线观看| 蜜桃久久av一区| 国产精品一色哟哟哟| 丰满亚洲少妇av| 91丨porny丨国产入口| 日本福利一区二区| 91高清视频在线| 欧美精品三级日韩久久| 日韩精品一区二区三区在线观看 | 亚洲品质自拍视频网站| 亚洲毛片av在线| 亚洲电影在线免费观看| 美女在线视频一区| 国产美女在线精品| 色综合天天视频在线观看| 欧美亚洲免费在线一区| 欧美一区国产二区| 欧美一区二区性放荡片| 久久久久九九视频| 精品日韩av一区二区| 国产精品女上位| 午夜av一区二区三区| 久久99热这里只有精品| 成人精品国产免费网站| 欧美性xxxxxxxx| 91精品福利在线一区二区三区| 久久亚洲精华国产精华液| 国产精品天美传媒| 亚洲三级在线看| 久久国内精品视频| 欧美性猛片aaaaaaa做受| 精品免费视频.| 一区二区三区四区在线播放| 综合久久久久久久| 一区二区视频在线看| 蜜臀av性久久久久av蜜臀妖精| 波多野结衣一区二区三区| 91麻豆精品国产91久久久| 国产精品国产自产拍高清av| 亚洲人成网站影音先锋播放| 国产精品自拍一区| 欧美日本一区二区在线观看| 久久美女艺术照精彩视频福利播放| 一区二区三区欧美久久| 天堂成人免费av电影一区| 99久久精品免费精品国产| 日韩欧美一级精品久久| 一区二区免费在线| 久久精品国产久精国产| 欧美调教femdomvk| 亚洲欧美日韩国产成人精品影院 | 欧美日韩一区国产| 18涩涩午夜精品.www| 国产福利电影一区二区三区| 欧美挠脚心视频网站| 国产情人综合久久777777| 三级精品在线观看| 欧美日韩综合色| 亚洲欧美色综合| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 91蝌蚪国产九色| 欧美高清在线精品一区| 国产激情视频一区二区三区欧美| 91精品国产综合久久精品app | 精品国产91乱码一区二区三区| 亚洲综合另类小说| 色先锋资源久久综合| 亚洲欧美电影一区二区| 国产精品一级片| 精品国产1区2区3区| 韩国午夜理伦三级不卡影院| 精品美女被调教视频大全网站| 青青草97国产精品免费观看无弹窗版| 色94色欧美sute亚洲线路二| 亚洲精品国产无天堂网2021| 97国产一区二区| 夜夜精品视频一区二区| 欧美男男青年gay1069videost| 日韩欧美在线一区二区三区| 激情深爱一区二区| 国产日产欧美一区| 91蝌蚪国产九色| 天天综合天天做天天综合| 91精品视频网| 国产精品一品视频| 国产精品毛片无遮挡高清| 成人精品一区二区三区四区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 国产精品人妖ts系列视频| av一区二区三区黑人| 玉足女爽爽91| 日韩一级视频免费观看在线| 国产成人在线观看| 国产精品美女久久久久aⅴ| 色久综合一二码| 青青草精品视频| 国产精品蜜臀在线观看| 91网站黄www| 日韩国产欧美一区二区三区| 色一情一伦一子一伦一区| 奇米色一区二区| 欧美日韩亚洲综合在线| 国产综合久久久久久鬼色| 精品88久久久久88久久久| 国产老妇另类xxxxx| 一区二区欧美精品| 欧美日韩精品是欧美日韩精品| 午夜精品成人在线视频| 日韩视频在线你懂得| 成人av动漫在线| 中文字幕亚洲一区二区av在线| 日本伦理一区二区| 免费精品视频在线| 久久久久久99精品| 欧美色偷偷大香| 不卡视频免费播放| 精品一区二区三区香蕉蜜桃| 亚洲女同ⅹxx女同tv| 国产性天天综合网| 97精品久久久久中文字幕| 无吗不卡中文字幕| 国产精品美女久久福利网站| 精品国产成人系列| 欧美肥胖老妇做爰| 一本色道久久综合亚洲91 | 日日夜夜精品免费视频| 日韩午夜小视频| 欧美在线观看一二区| 美国十次综合导航| 性感美女久久精品| 一区在线观看免费| 26uuu另类欧美| 欧美电影免费观看高清完整版| 欧洲色大大久久| 色婷婷亚洲一区二区三区| 国产成人综合亚洲网站| 精品综合免费视频观看| 一区二区三区在线观看动漫| 日本一区二区视频在线| 久久这里都是精品| 欧美不卡激情三级在线观看| 91精品国产麻豆| 日韩欧美色电影| 欧美一区二区三区免费大片 | 欧美v亚洲v综合ⅴ国产v| 欧美性色综合网| 在线观看日韩毛片| 欧洲精品一区二区| 在线免费不卡电影| 欧美日韩一区二区三区不卡 | 国产成人亚洲综合a∨猫咪| 奇米一区二区三区av| 亚洲大尺度视频在线观看| 日韩精品亚洲一区| 国产曰批免费观看久久久| 美女视频一区二区三区| 国产成人亚洲综合a∨婷婷图片| 成人性生交大片| 91国模大尺度私拍在线视频| thepron国产精品| 日本韩国欧美一区二区三区| 欧美中文字幕一区| 欧美精品免费视频| 久久久久久久久久美女| 国产精品视频观看| 亚洲综合男人的天堂| 午夜精品久久久久久久99水蜜桃| 五月综合激情网| 韩国女主播一区| 国产成人精品免费看| 欧美精品久久天天躁| 亚洲精品一区二区三区精华液| 国产亚洲va综合人人澡精品|