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

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

?? dibapi.cpp

?? 《精通 vc++ 圖像編程》的源代碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號(hào):
 
    // 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; 
    GlobalUnlock(hDIB); 
 
    // if the driver did not fill in the biSizeImage field, make one up  
    if (bi.biSizeImage == 0) 
        bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight; 
 
    // realloc the buffer big enough to hold all the bits 
 
    dwLen = bi.biSize + PaletteSize((LPBYTE)&bi) + bi.biSizeImage; 
 
    if (h = GlobalReAlloc(hDIB, dwLen, 0)) 
        hDIB = h; 
    else 
    { 
        // clean up and return NULL 
 
        GlobalFree(hDIB); 
        hDIB = NULL; 
        SelectPalette(hDC, hPal, TRUE); 
        RealizePalette(hDC); 
        ReleaseDC(NULL, hDC); 
        return NULL; 
    } 
 
    // lock memory block and get pointer to it */ 
 
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB); 
 
    // call GetDIBits with a NON-NULL lpBits param, and actualy get the 
    // bits this time 
 
    if (GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, (LPBYTE)lpbi + 
            (WORD)lpbi->biSize + PaletteSize((LPBYTE)lpbi), (LPBITMAPINFO)lpbi, 
            DIB_RGB_COLORS) == 0) 
    { 
        // clean up and return NULL 
 
        GlobalUnlock(hDIB); 
        hDIB = NULL; 
        SelectPalette(hDC, hPal, TRUE); 
        RealizePalette(hDC); 
        ReleaseDC(NULL, hDC); 
        return NULL; 
    } 
 
    bi = *lpbi; 
 
    // clean up  
    GlobalUnlock(hDIB); 
    SelectPalette(hDC, hPal, TRUE); 
    RealizePalette(hDC); 
    ReleaseDC(NULL, hDC); 
 
    // return handle to the DIB 
    return hDIB; 
} 
 
/************************************************************************* 
 * 
 * BitmapToDIB() 
 * 
 * Parameters: 
 * 
 * HBITMAP hBitmap  - specifies the bitmap to convert 
 * 
 * HPALETTE hPal    - specifies the palette to use with the bitmap 
 * 
 * WORD wBitCount   - specifies the DIB colorbits 
 *
 * 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 hPalette, WORD wBitCount)
{ 
	HDIB hNewDib;

	if (! hBitmap)
        return NULL; 

	// get bitmap info
	BITMAP  bm;         // bitmap structure 
	GetObject(hBitmap, sizeof(bm), (LPBYTE)&bm); 
	int 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; 

	// get DIB handle from current bitmap
	HDIB hDib = BitmapToDIB(hBitmap, hPalette);
	if (! hDib)
        return NULL; 

	if (wBitCount == biBits)
		hNewDib = hDib;
	else
	{
	    // DIB bits/pixel is not the same as device
		// convert dib format to accordingly
		hNewDib = ConvertDIBFormat(hDib, wBitCount, hPalette);
		// cleanup hDib
		GlobalFree(hDib);
	}

	return hNewDib;
} 


/************************************************************************* 
 * 
 * ChangeBitmapFormat() 
 * 
 * Parameter: 
 * 
 * HBITMAP          - handle to a bitmap 
 * 
 * WORD             - desired bits per pixel 
 * 
 * DWORD            - desired compression format 
 * 
 * HPALETTE         - handle to palette 
 * 
 * Return Value: 
 * 
 * HDIB             - handle to the new DIB if successful, else NULL 
 * 
 * Description: 
 * 
 * This function will convert a bitmap to the specified bits per pixel 
 * and compression format. The bitmap and it's palette will remain 
 * after calling this function. 
 * 
 ************************************************************************/ 
HDIB ChangeBitmapFormat (HBITMAP hbm, WORD biBits, DWORD biCompression, HPALETTE hpal)
{
    BITMAP               bm;
    BITMAPINFOHEADER     bi;
    LPBITMAPINFOHEADER   lpbi;
    DWORD                dwLen;
    HANDLE               hdib;
    HANDLE               h;
    HDC                  hdc;

    if (!hbm)
        return NULL;

    if (hpal == NULL)
        hpal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);

    GetObject(hbm,sizeof(bm),(LPBYTE)&bm);

    if (biBits == 0)
	{
        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; 
	}

    bi.biSize               = sizeof(BITMAPINFOHEADER);
    bi.biWidth              = bm.bmWidth;
    bi.biHeight             = bm.bmHeight;
    bi.biPlanes             = 1;
    bi.biBitCount           = biBits;
    bi.biCompression        = biCompression;
    bi.biSizeImage          = 0;
    bi.biXPelsPerMeter      = 0;
    bi.biYPelsPerMeter      = 0;
    bi.biClrUsed            = 0;
    bi.biClrImportant       = 0;

    dwLen  = bi.biSize + PaletteSize((LPBYTE)&bi);

    hdc = GetDC(NULL);
    HPALETTE hpalT = SelectPalette(hdc,hpal,FALSE);
    RealizePalette(hdc);

    hdib = GlobalAlloc(GHND,dwLen);

    if (!hdib)
	{
        SelectPalette(hdc,hpalT,FALSE);
        ReleaseDC(NULL,hdc);
        return NULL;
    }

    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hdib);

    *lpbi = bi;

    /*  call GetDIBits with a NULL lpBits param, so it will calculate the
     *  biSizeImage field for us
     */
    GetDIBits(hdc, hbm, 0L, (DWORD)bi.biHeight,
        (LPBYTE)NULL, (LPBITMAPINFO)lpbi, (DWORD)DIB_RGB_COLORS);

    bi = *lpbi;
    GlobalUnlock(hdib);

    /* If the driver did not fill in the biSizeImage field, make one up */
    if (bi.biSizeImage == 0)
	{
        bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;

        if (biCompression != BI_RGB)
            bi.biSizeImage = (bi.biSizeImage * 3) / 2;
    }

    /*  realloc the buffer big enough to hold all the bits */
    dwLen = bi.biSize + PaletteSize((LPBYTE)&bi) + bi.biSizeImage;
    if (h = GlobalReAlloc(hdib,dwLen,0))
        hdib = h;
    else
	{
        GlobalFree(hdib);
        hdib = NULL;

        SelectPalette(hdc,hpalT,FALSE);
        ReleaseDC(NULL,hdc);
        return hdib;
    }

    /*  call GetDIBits with a NON-NULL lpBits param, and actualy get the
     *  bits this time
     */
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hdib);

    if (! GetDIBits(hdc,
                    hbm,
                    0L,
                    (DWORD)bi.biHeight,
                    (LPBYTE)lpbi + (WORD)lpbi->biSize + PaletteSize((LPBYTE)lpbi),
                    (LPBITMAPINFO)lpbi, 
					(DWORD)DIB_RGB_COLORS))
	{
         GlobalUnlock(hdib);
         hdib = NULL;
         SelectPalette(hdc,hpalT,FALSE);
         ReleaseDC(NULL,hdc);
         return NULL;
    }
    bi = *lpbi;
   
	GlobalUnlock(hdib);
    SelectPalette(hdc,hpalT,FALSE);
    ReleaseDC(NULL,hdc);
    return hdib;
}


/************************************************************************* 
 * 
 * ChangeDIBFormat() 
 * 
 * Parameter: 
 * 
 * HDIB             - handle to packed-DIB in memory 
 * 
 * WORD             - desired bits per pixel 
 * 
 * DWORD            - desired compression format 
 * 
 * Return Value: 
 * 
 * HDIB             - handle to the new DIB if successful, else NULL 
 * 
 * Description: 
 * 
 * This function will convert the bits per pixel and/or the compression 
 * format of the specified DIB. Note: If the conversion was unsuccessful, 
 * we return NULL. The original DIB is left alone. Don't use code like the 
 * following: 
 * 
 *    hMyDIB = ChangeDIBFormat(hMyDIB, 8, BI_RLE4); 
 * 
 * The conversion will fail, but hMyDIB will now be NULL and the original 
 * DIB will now hang around in memory. We could have returned the old 
 * DIB, but we wanted to allow the programmer to check whether this 
 * conversion succeeded or failed. 
 * 
 ************************************************************************/ 
HDIB ChangeDIBFormat(HDIB hDIB, WORD wBitCount, DWORD dwCompression) 
{ 
    HBITMAP            hBitmap;         // Handle to bitmap 
    HDIB               hNewDIB = NULL;  // Handle to new DIB 
    HPALETTE           hPal;			// Handle to palette

    // Check for a valid DIB handle 
 
    if (!hDIB) 
        return NULL; 
 
    // Save the old DIB's palette 
 
    hPal = CreateDIBPalette(hDIB); 
    if (hPal == NULL)
        hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
 
    // Convert old DIB to a bitmap 
 
    hBitmap = DIBToBitmap(hDIB, hPal); 
    if (!hBitmap) 
    { 
        DeleteObject(hPal); 
        return NULL; 
    } 

	// Change bitmap format

	hNewDIB = ChangeBitmapFormat(hBitmap, wBitCount, dwCompression, hPal);
 
    // Clean up and return 
 
    DeleteObject(hBitmap); 
    DeleteObject(hPal); 
 
    return hNewDIB; 
} 
 

/**************************************************************************** 
* 
*     FUNCTION: ConvertDIBFormat 
* 
*     PURPOSE:  Creates a new DIB of the requested format, copies the source 
*               image to the new DIB. 
* 
*     PARAMS:   LPBITMAPINFO lpSrcDIB - the source CF_DIB 
*               UINT         nWidth   - width for new DIB 
*               UINT         nHeight  - height for new DIB 
*               UINT         nbpp     - bpp for new DIB 
*               BOOL         bStretch - TRUE to stretch source to dest 
*                                       FALSE to take upper left of image 
*				HPALETTE	 hPalSrc  - Palette used to set new DIB
*				DWORD		 dwSize   - return the size of new DIB pointer
* 
*     RETURNS:  HDIB - Handle of CF_DIB memory block with new image 
*               NULL on failure 
* 
\****************************************************************************/ 
HDIB ConvertDIBFormat(LPBYTE lpDIB, UINT nWidth, UINT nHeight, UINT nbpp, BOOL bStretch, HPALETTE hPalSrc) 
{ 
	LPBITMAPINFO lpSrcDIB =  (LPBITMAPINFO)lpDIB;
    LPBITMAPINFO lpbmi = NULL; 
    LPBYTE       lpSourceBits, lpTargetBits, lpResult; 
    HDC			 hDC = NULL, hSourceDC, hTargetDC; 
    HBITMAP      hSourceBitmap, hTargetBitmap, hOldTargetBitmap, hOldSourceBitmap; 
    DWORD        dwSourceBitsSize, dwTargetBitsSize, dwTargetHeaderSize, dwColorNum; 
	HDIB		 hDib;
 
    // Allocate and fill out a BITMAPINFO struct for the new DIB 
    if (nbpp <= 8) 
		dwColorNum = 1 << nbpp;
	else

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99国产精品国产精品毛片| 国产精品久久久久aaaa| 欧美日韩精品福利| 欧美亚洲综合色| 欧美午夜影院一区| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲欧美日韩国产手机在线| 国产精品乱码人人做人人爱| 国产精品美女久久久久久2018 | 国产一区 二区| 国产在线精品不卡| 成人激情综合网站| 91网站最新地址| 一本久久综合亚洲鲁鲁五月天| 一道本成人在线| 欧美三级乱人伦电影| 91精品在线免费| 欧美电视剧在线观看完整版| 久久久久久久久久久久电影| 久久久综合精品| 国产精品女主播av| 亚洲综合偷拍欧美一区色| 亚洲大片免费看| 日韩精品视频网| 国产自产2019最新不卡| 成人视屏免费看| 日本乱人伦aⅴ精品| 91精品欧美久久久久久动漫| 亚洲精品一区二区三区四区高清| 日本一区二区三区免费乱视频 | 成人国产电影网| 色www精品视频在线观看| 5858s免费视频成人| 国产亚洲美州欧州综合国| 国产精品毛片久久久久久| 一区二区三区在线观看国产| 日韩成人伦理电影在线观看| 国产凹凸在线观看一区二区| 91国内精品野花午夜精品| 欧美一区在线视频| 中文字幕欧美三区| 亚洲777理论| 国产精品一二二区| 在线观看一区二区视频| 精品久久久三级丝袜| 最近日韩中文字幕| 男男gaygay亚洲| eeuss鲁片一区二区三区| 欧美日本韩国一区二区三区视频| 国产亚洲污的网站| 亚洲福利视频一区二区| 国产一区二区美女诱惑| 在线精品国精品国产尤物884a| 日韩一区二区免费电影| 中文字幕在线观看一区| 老司机一区二区| 91首页免费视频| 久久亚洲精华国产精华液| 亚洲九九爱视频| 国产一区二区三区四区五区入口| 色婷婷久久99综合精品jk白丝| 日韩精品一区二区三区中文不卡 | 亚洲欧美怡红院| 肉肉av福利一精品导航| 成人h版在线观看| 欧美大片日本大片免费观看| 亚洲欧美国产毛片在线| 黑人精品欧美一区二区蜜桃 | 日韩精品一区国产麻豆| 亚洲六月丁香色婷婷综合久久| 久久不见久久见免费视频7| 欧美性xxxxxx少妇| 国产精品丝袜一区| 免费看日韩a级影片| 一本一道久久a久久精品 | 婷婷成人综合网| 91亚洲精品久久久蜜桃网站| 精品福利av导航| 秋霞电影一区二区| 在线视频你懂得一区| 国产精品拍天天在线| 国产麻豆视频一区| 日韩一级免费观看| 夜夜嗨av一区二区三区四季av| 成人黄动漫网站免费app| 日韩久久免费av| 蜜臀av国产精品久久久久| 欧美性猛交xxxx黑人交| 亚洲欧美一区二区三区孕妇| 高清视频一区二区| 国产亚洲综合色| 国产一区二区电影| 2020国产精品| 黄网站免费久久| 久久天天做天天爱综合色| 另类的小说在线视频另类成人小视频在线 | 国产老肥熟一区二区三区| 日韩欧美一区二区三区在线| 人禽交欧美网站| 7777女厕盗摄久久久| 石原莉奈在线亚洲三区| 欧美人动与zoxxxx乱| 亚洲福利一区二区| 欧美美女bb生活片| 日韩国产高清影视| 日韩欧美中文一区二区| 天堂精品中文字幕在线| 欧美另类久久久品| 亚洲不卡在线观看| 欧美一二三区精品| 久久超碰97中文字幕| www国产亚洲精品久久麻豆| 国产在线看一区| 中文无字幕一区二区三区| 国产91清纯白嫩初高中在线观看| 日本一区二区免费在线观看视频 | 波多野结衣在线一区| 自拍视频在线观看一区二区| 色94色欧美sute亚洲线路一久| 亚洲一区二区中文在线| 欧美精品色一区二区三区| 日韩和的一区二区| 欧美成人伊人久久综合网| 国产成人免费av在线| 亚洲欧美一区二区三区久本道91| 欧美在线一区二区三区| 日韩综合小视频| 久久精品网站免费观看| 99久久久久久99| 丝袜脚交一区二区| 久久久亚洲高清| 91污在线观看| 奇米一区二区三区av| 国产日韩在线不卡| 色屁屁一区二区| 日韩av一级电影| 中文字幕第一页久久| 在线精品国精品国产尤物884a| 日av在线不卡| 国产精品久久看| 欧美福利视频一区| 国产乱码一区二区三区| 亚洲欧美一区二区三区久本道91 | 中日韩免费视频中文字幕| 欧美中文字幕久久| 经典三级在线一区| 国产精品不卡在线| 欧美一区永久视频免费观看| 国产一区二区三区免费观看| 亚洲美女视频一区| 亚洲精品一区二区三区影院| 色成年激情久久综合| 精品亚洲国产成人av制服丝袜| 亚洲视频狠狠干| 精品av综合导航| 欧美吞精做爰啪啪高潮| 国产精品羞羞答答xxdd | 色乱码一区二区三区88| 开心九九激情九九欧美日韩精美视频电影 | 一区二区三区四区不卡在线 | 国产精品一区二区在线播放| 一区二区三区高清在线| 精品播放一区二区| 欧美日韩你懂得| 成人动漫视频在线| 久久超碰97中文字幕| 亚洲福利视频导航| 国产精品视频免费| 欧美va亚洲va| 欧美午夜精品一区二区三区| 成人一区二区视频| 久久国产三级精品| 午夜av一区二区| 亚洲日本电影在线| 国产欧美视频在线观看| 日韩欧美在线综合网| 欧美性生活久久| 99re热视频精品| 成人黄色大片在线观看| 国产一区二区三区黄视频 | 欧洲一区在线电影| 成熟亚洲日本毛茸茸凸凹| 久久99精品久久久| 日韩黄色小视频| 午夜精彩视频在线观看不卡| 亚洲欧美日韩国产手机在线| 中文一区一区三区高中清不卡| 精品国产制服丝袜高跟| 欧美一区二区免费| 337p亚洲精品色噜噜噜| 欧美色涩在线第一页| 91啪亚洲精品| 99精品欧美一区二区三区综合在线| 国产在线精品一区二区夜色| 麻豆免费看一区二区三区| 肉丝袜脚交视频一区二区| 天天综合日日夜夜精品| 天天综合天天综合色| 天堂蜜桃一区二区三区| 午夜亚洲福利老司机|