亚洲欧美第一页_禁久久精品乱码_粉嫩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" 

////////////////////////////////////////////////////////////////////////////////////
// Local use only function prototypes
////////////////////////////////////////////////////////////////////////////////////
BOOL CopyColorTable(LPBITMAPINFO lpTarget, LPBITMAPINFO lpSource, HPALETTE hPalSrc);
void DecreaseContrast(BYTE *pByte, const int Level, const float Grad);
void IncreaseContrast(BYTE *pByte, const int Low, const int High, const float Grad);
double Value(double n1, double n2, double hue);
HGLOBAL DitherImage(LPBYTE lpImageData, WORD Width, WORD Height);
void DitherLine(WORD Width, LPBYTE pLine1, LPBYTE pLine2);
////////////////////////////////////////////////////////////////////////////////////
 
/************************************************************************* 
 * 
 * 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 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人高清在线| 亚洲国产精品久久久久婷婷884| 日本丰满少妇一区二区三区| 捆绑紧缚一区二区三区视频| 成人欧美一区二区三区小说| 日韩欧美国产综合| 色狠狠综合天天综合综合| 久久国产精品第一页| 一卡二卡欧美日韩| 国产欧美一二三区| 欧美精品成人一区二区三区四区| 粉嫩av一区二区三区粉嫩| 另类小说一区二区三区| 亚洲一区在线视频观看| 国产精品无遮挡| 欧美r级在线观看| 欧美日本国产一区| www.在线欧美| 国产精品亚洲视频| 免费在线观看不卡| 亚洲福中文字幕伊人影院| 日韩欧美一级在线播放| 色美美综合视频| 国产91精品免费| 国产一区二区视频在线| 蜜臀久久久99精品久久久久久| 亚洲男人天堂一区| 国产精品网曝门| 国产亚洲一区字幕| 欧美变态口味重另类| 5月丁香婷婷综合| 欧美色网站导航| 在线亚洲一区观看| 色综合色综合色综合色综合色综合 | 亚洲人精品午夜| 国产亚洲欧美激情| 久久久久97国产精华液好用吗| 日韩欧美卡一卡二| 精品国产一区二区三区四区四| 日韩一级在线观看| 日韩亚洲欧美中文三级| 欧美一级爆毛片| 日韩一区二区视频| 日韩一区二区三区高清免费看看 | 中文字幕不卡在线| 久久婷婷国产综合精品青草| 2021久久国产精品不只是精品| 欧美成人bangbros| 久久久国际精品| 日本一区二区成人| 国产精品久久久久久久裸模| 亚洲少妇中出一区| 亚洲第一综合色| 日本va欧美va精品发布| 久久成人免费网站| 高清免费成人av| 91丨porny丨户外露出| 一本色道**综合亚洲精品蜜桃冫| 色欧美片视频在线观看在线视频| 色偷偷成人一区二区三区91| 色婷婷精品久久二区二区蜜臀av| 欧美三区在线观看| 欧美一区二区三区免费| 精品国产精品网麻豆系列| 精品对白一区国产伦| 国产精品美日韩| 亚洲精品美国一| 免费在线观看一区| 床上的激情91.| 色婷婷国产精品综合在线观看| 5566中文字幕一区二区电影| 日韩欧美一级二级三级久久久| 国产拍欧美日韩视频二区| 亚洲三级久久久| 青青草97国产精品免费观看无弹窗版 | 欧美精品一二三四| 日韩精品一区二区三区老鸭窝| 国产午夜精品一区二区三区视频| 亚洲视频在线一区| 美女性感视频久久| av资源网一区| 91精品国产91综合久久蜜臀| 久久综合狠狠综合久久综合88 | 麻豆高清免费国产一区| 成人av网站免费观看| 欧美精品丝袜久久久中文字幕| 久久午夜电影网| 一区二区三区毛片| 国产做a爰片久久毛片| 色综合天天综合网天天看片 | 国产精品福利影院| 日本一不卡视频| 国产91富婆露脸刺激对白| 欧美在线综合视频| 久久人人爽人人爽| 无码av免费一区二区三区试看| 国产乱子轮精品视频| 欧美日韩中文一区| 亚洲国产成人自拍| 日本成人超碰在线观看| 9i看片成人免费高清| 日韩欧美一二三四区| 亚洲一区二区三区四区五区中文 | 欧美不卡在线视频| 亚洲黄色尤物视频| 国产精品一线二线三线精华| 欧美日韩国产精品自在自线| 中文字幕中文字幕一区| 国产麻豆91精品| 日韩欧美亚洲国产精品字幕久久久| 中文字幕亚洲一区二区av在线| 久久精品999| 91麻豆精品国产自产在线| 最新日韩av在线| 国产精品亚洲专一区二区三区| 欧美日本高清视频在线观看| 亚洲精品第一国产综合野| 成人免费福利片| 26uuuu精品一区二区| 日本色综合中文字幕| 欧美亚日韩国产aⅴ精品中极品| 国产精品对白交换视频| 福利电影一区二区三区| 精品免费一区二区三区| 日韩av电影免费观看高清完整版| 91福利精品第一导航| 中文字幕中文字幕在线一区| 国产成人久久精品77777最新版本| 欧美成人精精品一区二区频| 三级影片在线观看欧美日韩一区二区 | 色综合天天综合网天天狠天天| 日本一区二区三区高清不卡| 国内精品国产成人国产三级粉色| 91精品国产综合久久小美女| 亚洲成av人片www| 欧美午夜在线一二页| 亚洲一区二区三区爽爽爽爽爽| 欧日韩精品视频| 一区二区三区欧美亚洲| 91国产福利在线| 国产精品系列在线| 午夜久久久久久久久| 色吧成人激情小说| 亚洲资源在线观看| 欧美午夜精品理论片a级按摩| 亚洲乱码中文字幕综合| 欧美在线免费播放| 亚洲成人av一区二区三区| 欧美日韩国产片| 视频一区视频二区在线观看| 91精品欧美一区二区三区综合在| 免费在线一区观看| 精品成人一区二区三区四区| 国产精品一区二区91| 国产情人综合久久777777| av激情亚洲男人天堂| 亚洲与欧洲av电影| 欧美日韩国产美女| 黑人巨大精品欧美一区| 久久精品人人做人人爽97| 99re成人精品视频| 亚洲在线视频一区| 日韩色视频在线观看| 国产精品一区二区黑丝| 国产精品美女久久久久久久久久久| aaa欧美色吧激情视频| 亚洲一二三专区| 日韩欧美黄色影院| 成人av动漫在线| 亚洲妇女屁股眼交7| 精品日产卡一卡二卡麻豆| 不卡免费追剧大全电视剧网站| 亚洲一区二区三区美女| 日韩欧美中文字幕公布| 成人亚洲精品久久久久软件| 一区二区三区国产精华| 欧美一区二区三区啪啪| 成人黄色777网| 亚洲第一激情av| 欧美激情一区二区| 欧美私人免费视频| 国产一区二区三区观看| 亚洲精品福利视频网站| 2022国产精品视频| 色天天综合久久久久综合片| 日本sm残虐另类| 亚洲女人的天堂| 日韩美女在线视频| 色94色欧美sute亚洲线路一ni| 久久99精品国产麻豆婷婷洗澡| 中文成人av在线| 日韩一级二级三级| 91美女视频网站| 黄网站免费久久| 亚洲自拍另类综合| 国产精品嫩草99a| 欧美一级片免费看| 日本道在线观看一区二区| 国产精品亚洲а∨天堂免在线| 亚洲成人tv网|