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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 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; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
性做久久久久久久久| 一区二区三区自拍| 国产成人免费视频精品含羞草妖精| 日韩欧美三级在线| 国产一区在线观看麻豆| 中文字幕av一区 二区| 99精品欧美一区二区蜜桃免费 | 色呦呦网站一区| 一区二区三区自拍| 3d动漫精品啪啪一区二区竹菊| 久久69国产一区二区蜜臀| 久久久亚洲高清| 色狠狠综合天天综合综合| 偷拍亚洲欧洲综合| 国产日韩影视精品| 日本高清无吗v一区| 美腿丝袜在线亚洲一区| 欧美国产欧美综合| 欧美日韩国产在线播放网站| 国产在线播放一区三区四| 亚洲天堂成人在线观看| 日韩欧美中文一区二区| 99精品久久免费看蜜臀剧情介绍| 五月综合激情日本mⅴ| 久久久久久日产精品| 色综合夜色一区| 国内欧美视频一区二区 | 精品国产一区二区三区忘忧草| 高清shemale亚洲人妖| 日日摸夜夜添夜夜添亚洲女人| 国产午夜精品久久久久久久| 欧美亚洲丝袜传媒另类| 精品无人码麻豆乱码1区2区 | 国产精品久久久久久久久免费丝袜| 欧美午夜在线观看| 国产99精品在线观看| 亚洲国产毛片aaaaa无费看| 国产亚洲美州欧州综合国| 3d动漫精品啪啪一区二区竹菊| 99久久亚洲一区二区三区青草| 日本特黄久久久高潮| 亚洲天堂网中文字| 久久久久免费观看| 7777精品伊人久久久大香线蕉 | 精品一区二区在线视频| 亚洲裸体在线观看| 中文字幕第一区| 久久先锋影音av鲁色资源| 欧美久久久久久蜜桃| 色视频成人在线观看免| 国产成人精品免费视频网站| 日本欧美肥老太交大片| 亚洲图片欧美综合| 中文字幕亚洲区| 欧美韩国日本一区| 久久精品免费在线观看| 欧美videossexotv100| 欧美日本国产视频| 欧美视频日韩视频在线观看| 99久久精品国产一区二区三区| 国产一区二区久久| 狠狠色狠狠色综合系列| 日韩电影在线观看一区| 日韩av在线发布| 亚洲欧美另类久久久精品2019| www国产成人免费观看视频 深夜成人网| 欧美片在线播放| 欧美性xxxxx极品少妇| 99精品国产99久久久久久白柏| 国产综合色产在线精品| 奇米四色…亚洲| 日本色综合中文字幕| 亚洲va国产天堂va久久en| 亚洲精品你懂的| 日韩一区欧美一区| 国产精品久久久久影院老司| 国产免费成人在线视频| 久久久91精品国产一区二区三区| 欧美一区二区不卡视频| 日韩美女一区二区三区四区| 日韩欧美成人激情| 日韩午夜在线影院| 精品免费日韩av| 久久夜色精品一区| 国产欧美日韩在线| 国产精品免费av| 日韩毛片在线免费观看| 一区二区国产视频| 午夜精品久久久久久久久| 天堂午夜影视日韩欧美一区二区| 天天影视色香欲综合网老头| 热久久国产精品| 激情综合网最新| 国产成人免费在线观看不卡| av色综合久久天堂av综合| 97精品国产97久久久久久久久久久久| 91黄色激情网站| 91精品国产综合久久香蕉麻豆| 精品国产99国产精品| 欧美国产激情一区二区三区蜜月 | 337p亚洲精品色噜噜噜| 91精品国产入口| 日本一区二区三区电影| 亚洲精品乱码久久久久久久久| 性久久久久久久久久久久| 亚洲精品在线一区二区| 亚洲成va人在线观看| 日韩av电影免费观看高清完整版 | k8久久久一区二区三区| 91色视频在线| 精品视频1区2区3区| 日韩欧美一区二区免费| 国产精品美女久久久久久久久 | eeuss鲁片一区二区三区在线观看| 一本在线高清不卡dvd| 91精品国产一区二区人妖| 国产欧美日韩在线视频| 香蕉影视欧美成人| 国产69精品久久777的优势| 欧美日韩你懂得| 国产精品国产三级国产普通话三级 | 欧美日韩在线不卡| 日韩精品一区二区在线| 中文字幕制服丝袜一区二区三区 | 国产精品一区二区男女羞羞无遮挡| 99在线精品观看| 精品国产免费一区二区三区四区| 一区二区三区中文免费| 国内欧美视频一区二区| 欧美亚洲国产bt| 国产精品沙发午睡系列990531| 日韩电影在线一区二区三区| av资源站一区| 精品国产欧美一区二区| 亚洲成人福利片| 97精品久久久久中文字幕| 国产无人区一区二区三区| 日本系列欧美系列| 欧美三区在线视频| 亚洲美腿欧美偷拍| 成人国产精品免费观看动漫| 2021中文字幕一区亚洲| 日韩经典一区二区| 在线精品国精品国产尤物884a| 中文在线免费一区三区高中清不卡| 人人爽香蕉精品| 欧美精品乱码久久久久久| 亚洲黄网站在线观看| 暴力调教一区二区三区| 国产日产亚洲精品系列| 国产精品一线二线三线| 日韩精品一区国产麻豆| 蜜臀精品一区二区三区在线观看 | 国产电影一区二区三区| 日韩视频免费观看高清完整版在线观看 | 婷婷夜色潮精品综合在线| 91香蕉视频污在线| 国产精品成人在线观看| 99久久免费视频.com| 最新欧美精品一区二区三区| 成人免费看片app下载| 国产人成亚洲第一网站在线播放| 九一九一国产精品| 精品久久久久香蕉网| 精品一区二区三区在线播放| 欧美变态凌虐bdsm| 老司机精品视频线观看86| 日韩一区二区高清| 蜜桃精品视频在线| 日韩欧美成人一区| 国产精品自产自拍| 中文字幕不卡在线播放| 91香蕉国产在线观看软件| 一区二区三区欧美激情| 欧美日韩免费观看一区二区三区| 亚洲永久精品大片| 日韩一区二区三区免费观看| 国产成人av电影免费在线观看| 日韩美一区二区三区| 久久精品噜噜噜成人88aⅴ| 日韩三级av在线播放| 国产精品亚洲一区二区三区妖精 | 在线欧美一区二区| 亚洲欧美日韩电影| 91蝌蚪porny九色| 亚洲一二三区在线观看| 91精品一区二区三区久久久久久 | 一区二区三区在线不卡| 欧美日韩国产另类不卡| 美国毛片一区二区三区| 亚洲精品国产成人久久av盗摄| 色悠久久久久综合欧美99| 亚洲gay无套男同| 精品国产三级a在线观看| 波多野结衣中文一区| 亚洲国产人成综合网站| 精品久久久久久久久久久久久久久久久| 国产精品 欧美精品| 一区二区三区国产精华| 日韩欧美一区中文|