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

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

?? dibapi.cpp

?? 《精通 vc++ 圖像編程》的源代碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
	return dw;
} 

/**************************************************************************** 
* 
*     FUNCTION: DIBlockSize 
* 
*     PURPOSE:  Calculates the number of bytes in one scan line. 
* 
*     PARAMS:   LPBYTE lpDIB - pointer to the BITMAPINFOHEADER 
                              that begins the CF_DIB block 
* 
*     RETURNS:  DWORD - DIB block size
* 
\****************************************************************************/ 
DWORD DIBlockSize(LPBYTE lpDIB)
{
	if (((LPBITMAPINFOHEADER)lpDIB)->biSizeImage == 0)
		((LPBITMAPINFOHEADER)lpDIB)->biSizeImage = BytesPerLine(lpDIB) * ((LPBITMAPINFOHEADER)lpDIB)->biHeight;
	return ((LPBITMAPINFOHEADER)lpDIB)->biSize + PaletteSize(lpDIB) + ((LPBITMAPINFOHEADER)lpDIB)->biSizeImage;
}

DWORD DIBlockSize(HDIB hDIB) 
{ 
	LPBYTE lpDIB = (LPBYTE)GlobalLock(hDIB);
	DWORD dw = DIBlockSize(lpDIB);
	GlobalUnlock(hDIB);
	return dw;
} 
 
/************************************************************************* 
 * 
 * CreateDIBPalette() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpbi       - specifies the DIB 
 * 
 * Return Value: 
 * 
 * HPALETTE         - specifies the palette 
 * 
 * Description: 
 * 
 * This function creates a palette from a DIB by allocating memory for the 
 * logical palette, reading and storing the colors from the DIB's color table 
 * into the logical palette, creating a palette from this logical palette, 
 * and then returning the palette's handle. This allows the DIB to be 
 * displayed using the best possible colors (important for DIBs with 256 or 
 * more colors). 
 * 
 ************************************************************************/ 
HPALETTE CreateDIBPalette(LPBYTE lpbi) 
{ 
    LPLOGPALETTE        lpPal;          // pointer to a logical palette 
    HANDLE              hLogPal;        // handle to a logical palette 
    HPALETTE            hPal = NULL;    // handle to a palette 
    int                 i, wNumColors;  // loop index, number of colors in color table 
    LPBITMAPINFO        lpbmi;          // pointer to BITMAPINFO structure (Win3.0) 
    LPBITMAPCOREINFO    lpbmc;          // pointer to BITMAPCOREINFO structure (OS/2) 
    BOOL                bWinStyleDIB;   // Win3.0 DIB? 
 
    // if handle to DIB is invalid, return NULL 
 
    if (! lpbi) 
        return NULL; 
 
    // get pointer to BITMAPINFO (Win 3.0) 
 
    lpbmi = (LPBITMAPINFO)lpbi; 
 
    // get pointer to BITMAPCOREINFO (OS/2 1.x) 
 
    lpbmc = (LPBITMAPCOREINFO)lpbi; 
 
    // get the number of colors in the DIB  
 
    wNumColors = DIBNumColors(lpbi); 
 
    // is this a Win 3.0 DIB? 
 
    bWinStyleDIB = IS_WIN30_DIB(lpbi); 
    if (wNumColors) 
    { 
        // allocate memory block for logical palette 
 
        hLogPal = GlobalAlloc(GHND, sizeof(LOGPALETTE) + 
                sizeof(PALETTEENTRY) * wNumColors); 
 
        // if not enough memory, clean up and return NULL 
 
        if (!hLogPal) 
            return NULL; 
 
        // lock memory block and get pointer to it 
 
        lpPal = (LPLOGPALETTE)GlobalLock(hLogPal); 
 
        // set version and number of palette entries 
 
        lpPal->palVersion = PALVERSION; 
        lpPal->palNumEntries = wNumColors; 
 
        // store RGB triples (if Win 3.0 DIB) or RGB quads (if OS/2 DIB) 
        // into palette 
         
        for (i = 0; i < wNumColors; i++) 
        { 
            if (bWinStyleDIB) 
            { 
                lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed; 
                lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen; 
                lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue; 
                lpPal->palPalEntry[i].peFlags = 0; 
            } 
            else 
            { 
                lpPal->palPalEntry[i].peRed = lpbmc->bmciColors[i].rgbtRed; 
                lpPal->palPalEntry[i].peGreen = lpbmc->bmciColors[i].rgbtGreen; 
                lpPal->palPalEntry[i].peBlue = lpbmc->bmciColors[i].rgbtBlue; 
                lpPal->palPalEntry[i].peFlags = 0; 
            } 
        } 
 
        // create the palette and get handle to it 
 
        hPal = CreatePalette(lpPal); 
 
        // if error getting handle to palette, clean up and return NULL 
 
        if (!hPal) 
        { 
            GlobalUnlock(hLogPal); 
            GlobalFree(hLogPal); 
            return NULL; 
        } 
    } 
 
    // return handle to DIB's palette 
    return hPal; 
} 
 
/************************************************************************* 
 * 
 * CreateDIBPalette() 
 * 
 * Parameter: 
 * 
 * HDIB hDIB        - specifies the DIB 
 * 
 * Return Value: 
 * 
 * HPALETTE         - specifies the palette 
 * 
 * Description: 
 * 
 * This function creates a palette from a DIB by allocating memory for the 
 * logical palette, reading and storing the colors from the DIB's color table 
 * into the logical palette, creating a palette from this logical palette, 
 * and then returning the palette's handle. This allows the DIB to be 
 * displayed using the best possible colors (important for DIBs with 256 or 
 * more colors). 
 * 
 ************************************************************************/ 
HPALETTE CreateDIBPalette(HDIB hDIB) 
{ 
    HPALETTE            hPal = NULL;    // handle to a palette 
    LPBYTE               lpbi;           // pointer to packed-DIB 
 
    // if handle to DIB is invalid, return NULL 
 
    if (!hDIB) 
        return NULL; 
 
    // lock DIB memory block and get a pointer to it 
 
    lpbi = (LPBYTE)GlobalLock(hDIB); 
 
	hPal = CreateDIBPalette(lpbi);

	// Unlock hDIB
    GlobalUnlock(hDIB); 
 
    // return handle to DIB's palette 
    return hPal; 
} 
 
/************************************************************************* 
 * 
 * DIBToBitmap() 
 * 
 * Parameters: 
 * 
 * HDIB hDIB        - specifies the DIB to convert 
 * 
 * HPALETTE hPal    - specifies the palette to use with the bitmap 
 * 
 * Return Value: 
 * 
 * HBITMAP          - identifies the device-dependent bitmap 
 * 
 * Description: 
 * 
 * This function creates a bitmap from a DIB using the specified palette. 
 * If no palette is specified, default is used. 
 * 
 * NOTE: 
 * 
 * The bitmap returned from this funciton is always a bitmap compatible 
 * with the screen (e.g. same bits/pixel and color planes) rather than 
 * a bitmap with the same attributes as the DIB.  This behavior is by 
 * design, and occurs because this function calls CreateDIBitmap to 
 * do its work, and CreateDIBitmap always creates a bitmap compatible 
 * with the hDC parameter passed in (because it in turn calls 
 * CreateCompatibleBitmap). 
 * 
 * So for instance, if your DIB is a monochrome DIB and you call this 
 * function, you will not get back a monochrome HBITMAP -- you will 
 * get an HBITMAP compatible with the screen DC, but with only 2 
 * colors used in the bitmap. 
 * 
 * If your application requires a monochrome HBITMAP returned for a 
 * monochrome DIB, use the function SetDIBits(). 
 * 
 * Also, the DIBpassed in to the function is not destroyed on exit. This 
 * must be done later, once it is no longer needed. 
 * 
 ************************************************************************/ 
HBITMAP DIBToBitmap(HDIB hDIB, HPALETTE hPal) 
{ 
    LPBYTE       lpDIBHdr, lpDIBBits;  // pointer to DIB header, pointer to DIB bits 
    HBITMAP     hBitmap;            // handle to device-dependent bitmap 
    HDC         hDC;                    // handle to DC 
    HPALETTE    hOldPal = NULL;    // handle to a palette 
 
    // if invalid handle, return NULL  
 
    if (!hDIB) 
        return NULL; 
 
    // lock memory block and get a pointer to it 
 
    lpDIBHdr = (LPBYTE)GlobalLock(hDIB); 
 
    // get a pointer to the DIB bits 
 
    lpDIBBits = FindDIBBits(lpDIBHdr); 
 
    // get a DC  
 
    hDC = GetDC(NULL); 
    if (!hDC) 
    { 
        // clean up and return NULL 
        GlobalUnlock(hDIB); 
        return NULL; 
    } 
 
    // select and realize palette 
 
    if (hPal) 
	{
        hOldPal = SelectPalette(hDC, hPal, FALSE); 
	    RealizePalette(hDC); 
	}
 
    // create bitmap from DIB info and bits 
    hBitmap = CreateDIBitmap(hDC, 
							(LPBITMAPINFOHEADER)lpDIBHdr, 
							CBM_INIT, 
							lpDIBBits, 
							(LPBITMAPINFO)lpDIBHdr, 
							DIB_RGB_COLORS);
 
    // restore previous palette 
    if (hOldPal) 
        SelectPalette(hDC, hOldPal, FALSE); 
 
    // clean up 
    ReleaseDC(NULL, hDC); 
    GlobalUnlock(hDIB); 
 
    // return handle to the bitmap 
    return hBitmap; 
} 
 
 
/************************************************************************* 
 * 
 * BitmapToDIB() 
 * 
 * Parameters: 
 * 
 * HBITMAP hBitmap  - specifies the bitmap to convert 
 * 
 * HPALETTE hPal    - specifies the palette to use with the bitmap 
 * 
 * Return Value: 
 * 
 * HDIB             - identifies the device-dependent bitmap 
 * 
 * Description: 
 * 
 * This function creates a DIB from a bitmap using the specified palette. 
 * 
 ************************************************************************/ 
HDIB BitmapToDIB(HBITMAP hBitmap, HPALETTE hPal) 
{ 
    BITMAP              bm;         // bitmap structure 
    BITMAPINFOHEADER    bi;         // bitmap header 
    LPBITMAPINFOHEADER  lpbi;       // pointer to BITMAPINFOHEADER 
    DWORD               dwLen;      // size of memory block 
    HANDLE              hDIB, h;    // handle to DIB, temp handle 
    HDC                 hDC;        // handle to DC 
    WORD                biBits;     // bits per pixel 
 
    // check if bitmap handle is valid 
 
    if (!hBitmap) 
        return NULL; 
 
    // fill in BITMAP structure, return NULL if it didn't work 
 
    if (!GetObject(hBitmap, sizeof(bm), (LPBYTE)&bm)) 
        return NULL; 
 
    // if no palette is specified, use default palette 
 
    if (hPal == NULL) 
        hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE); 
 
    // calculate bits per pixel 
 
    biBits = bm.bmPlanes * bm.bmBitsPixel; 
 
    // make sure bits per pixel is valid 
 
    if (biBits <= 1) 
        biBits = 1; 
    else if (biBits <= 4) 
        biBits = 4; 
    else if (biBits <= 8) 
        biBits = 8; 
    else // if greater than 8-bit, force to 24-bit 
        biBits = 24; 
 
    // initialize BITMAPINFOHEADER 
 
    bi.biSize = sizeof(BITMAPINFOHEADER); 
    bi.biWidth = bm.bmWidth; 
    bi.biHeight = bm.bmHeight; 
    bi.biPlanes = 1; 
    bi.biBitCount = biBits; 
    bi.biCompression = BI_RGB; 
    bi.biSizeImage = 0; 
    bi.biXPelsPerMeter = 0; 
    bi.biYPelsPerMeter = 0; 
    bi.biClrUsed = 0; 
    bi.biClrImportant = 0; 
 
    // calculate size of memory block required to store BITMAPINFO 
 
    dwLen = bi.biSize + PaletteSize((LPBYTE)&bi); 
 
    // get a DC 
 
    hDC = GetDC(NULL); 
 
    // select and realize our palette 
 
    hPal = SelectPalette(hDC, hPal, FALSE); 
    RealizePalette(hDC); 
 
    // alloc memory block to store our bitmap 
 
    hDIB = GlobalAlloc(GHND, dwLen); 
 
    // if we couldn't get memory block 
 
    if (!hDIB) 
    { 
      // clean up and return NULL 
 
      SelectPalette(hDC, hPal, TRUE); 
      RealizePalette(hDC); 
      ReleaseDC(NULL, hDC); 
      return NULL; 
    } 
 
    // lock memory and get pointer to it 
 
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB); 
 
    /// use our bitmap info. to fill BITMAPINFOHEADER 
 
    *lpbi = bi; 
 
    // call GetDIBits with a NULL lpBits param, so it will calculate the 
    // biSizeImage field for us     
 
    GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, NULL, (LPBITMAPINFO)lpbi, 
        DIB_RGB_COLORS); 
 
    // get the info. returned by GetDIBits and unlock memory block 
 
    bi = *lpbi; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
看电影不卡的网站| 337p亚洲精品色噜噜噜| 蜜乳av一区二区三区| 亚洲一区二区中文在线| 亚洲欧美乱综合| 亚洲欧美日韩国产综合在线 | 日韩欧美精品在线| 91麻豆精品国产91久久久更新时间| 欧美亚洲图片小说| 欧美日韩一区二区在线观看视频 | 欧美日韩一区在线观看| 欧美日韩精品一区二区三区| 欧美日韩高清一区| 欧美一区二区女人| 精品国产乱码久久久久久浪潮 | 亚洲人成7777| 亚洲国产成人va在线观看天堂| 亚洲午夜一区二区| 日本不卡一区二区三区 | 欧美性感一类影片在线播放| 欧美视频一区在线观看| 久久久亚洲高清| 精品福利二区三区| 久久精品一区二区三区四区| 国产精品系列在线| 亚洲欧美另类图片小说| 亚洲第一久久影院| 精品一区二区三区久久| 国产成人一区在线| 色狠狠一区二区三区香蕉| 欧美日韩中文字幕精品| 日韩欧美亚洲另类制服综合在线| 久久亚洲二区三区| 中文字幕一区二区三中文字幕| 亚洲一区二区在线免费看| 日本少妇一区二区| 国产jizzjizz一区二区| 色哟哟精品一区| 欧美成人女星排行榜| 国产精品色噜噜| 亚洲成人免费影院| 激情成人综合网| 91一区二区三区在线观看| 欧美蜜桃一区二区三区| 久久综合国产精品| 亚洲乱码国产乱码精品精的特点| 一区二区三区中文字幕在线观看| 日韩电影一区二区三区| 成人高清视频在线| 日韩午夜av电影| 国产精品久久久久久久久久免费看| 亚洲午夜电影在线观看| 国产激情一区二区三区四区| 欧美在线观看一二区| 精品福利视频一区二区三区| 一区二区三区免费看视频| 狠狠色狠狠色综合系列| 色老综合老女人久久久| www国产成人| 亚洲图片欧美色图| 国产1区2区3区精品美女| 欧美人成免费网站| 亚洲日本一区二区| 韩国视频一区二区| 欧美日本国产视频| 亚洲欧美aⅴ...| 国产精品一区二区不卡| 欧美日韩免费高清一区色橹橹| 国产日韩精品一区二区三区| 日本特黄久久久高潮| 91福利在线播放| 国产精品久久影院| 国产麻豆视频一区二区| 91精品婷婷国产综合久久| 亚洲婷婷在线视频| 国产精品一区二区x88av| 日韩视频一区二区三区| 亚洲午夜国产一区99re久久| 99re热视频这里只精品| 国产午夜精品在线观看| 奇米影视在线99精品| 欧美日韩一级黄| 亚洲视频综合在线| 成人国产精品免费观看动漫| 久久女同精品一区二区| 久久精品国产久精国产| 69p69国产精品| 亚洲国产日产av| 色偷偷成人一区二区三区91| 欧美国产欧美综合| 国内精品在线播放| 精品少妇一区二区| 蜜桃久久精品一区二区| 欧美久久久久久久久久| 午夜视黄欧洲亚洲| 91福利视频在线| 亚洲综合999| 日本丶国产丶欧美色综合| 中文字幕佐山爱一区二区免费| 成人精品免费视频| 国产精品沙发午睡系列990531| 韩国精品在线观看| 久久―日本道色综合久久| 黄页视频在线91| 日韩视频国产视频| 美国十次了思思久久精品导航| 在线不卡免费欧美| 日本中文字幕一区二区有限公司| 欧美日韩国产美| 日韩—二三区免费观看av| 正在播放亚洲一区| 免费观看成人av| 精品国产一区二区三区不卡 | 欧美午夜一区二区三区免费大片| 亚洲综合色在线| 欧美日韩专区在线| 免费亚洲电影在线| 精品国产一区二区国模嫣然| 国产精品 欧美精品| 国产精品久久久久久户外露出 | 成人黄色在线网站| 亚洲图片另类小说| 在线看日本不卡| 亚洲a一区二区| 欧美一区二区三区喷汁尤物| 久草热8精品视频在线观看| 欧美精品一区二区三区四区| 国产成人丝袜美腿| 亚洲婷婷在线视频| 欧美高清视频不卡网| 乱一区二区av| 国产精品传媒视频| 91国偷自产一区二区使用方法| 午夜激情一区二区| 久久新电视剧免费观看| 不卡欧美aaaaa| 亚洲观看高清完整版在线观看| 91精品婷婷国产综合久久| 国产激情一区二区三区四区| 亚洲色图一区二区三区| 欧美日本在线观看| 国产精品资源站在线| 亚洲精品成人精品456| 欧美一级免费大片| 不卡一区在线观看| 日韩中文字幕av电影| 久久午夜电影网| 日本大香伊一区二区三区| 美女在线一区二区| 国产精品久久久久久久久图文区| 欧美日韩一区二区不卡| 国产精品自拍三区| 亚洲在线观看免费| 久久亚洲综合色一区二区三区| 一本到高清视频免费精品| 蜜桃久久av一区| 亚洲欧美色图小说| 337p粉嫩大胆噜噜噜噜噜91av| 一本色道久久综合亚洲精品按摩| 麻豆精品一区二区综合av| 中文字幕一区二区三区乱码在线| 欧美老人xxxx18| 国产福利不卡视频| 亚洲电影视频在线| 国产日韩一级二级三级| 欧美日韩aaaaa| 成人黄色在线看| 久久99精品久久久久久久久久久久| 1区2区3区精品视频| www国产亚洲精品久久麻豆| 精品视频免费在线| 99国产欧美久久久精品| 韩国av一区二区三区四区| 亚洲午夜日本在线观看| 国产精品久久看| 精品99999| 91精品久久久久久久99蜜桃 | 欧美日韩综合色| caoporn国产精品| 国产精品一区二区三区四区| 香蕉久久一区二区不卡无毒影院| 国产精品久久久久四虎| 亚洲精品一区二区三区福利| 欧美日韩免费在线视频| 一本色道久久综合精品竹菊| 国产mv日韩mv欧美| 国产自产2019最新不卡| 视频一区在线播放| 亚洲精品国产精华液| 欧美国产精品专区| 久久综合色8888| 欧美一级欧美三级在线观看| 欧美在线你懂的| 91久久精品一区二区| 91免费国产视频网站| 成人美女视频在线看| 国产精品资源在线看| 国产原创一区二区三区| 久久99精品国产.久久久久久 | 国产成人精品www牛牛影视|