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

////////////////////////////////////////////////////////////////////////////////////
// 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); 
} 
 
/************************************************************************* 
 * 
 * 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; 
    } 
    else 
    { 
        SetCursor(LoadCursor(NULL, IDC_ARROW)); 
        return NULL; 
    } 
} 
 
 
/************************************************************************* 
 * 
 * SaveDIB() 
 * 
 * Saves the specified DIB into the specified file name on disk.  No 
 * error checking is done, so if the file already exists, it will be 
 * written over. 
 * 
 * Parameters: 
 * 
 * HDIB hDib - Handle to the dib to save 
 * 
 * LPCTSTR lpFileName - pointer to full pathname to save DIB under 
 * 
 * Return value: TRUE if successful
 *				 FALSE if failure
 * 
 *************************************************************************/ 
BOOL SaveDIB(HDIB hDib, LPCTSTR lpFileName) 
{ 
    HANDLE              fh;         // file handle for opened file 
 
    if (!hDib) 
        return FALSE; 
 
    fh = CreateFile(lpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 
            FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); 
 
    if (fh == INVALID_HANDLE_VALUE) 
        return FALSE; 

	BOOL bSuccess = WriteDIBFile(hDib, fh);

    CloseHandle(fh);
	return bSuccess;
}

/************************************************************************* 
 * 
 * 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 > 8)	//(lpbi->biBitCount != 24) 
            nNumColors = 1 << lpbi->biBitCount; // standard size table 
    } 
 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色噜噜久久综合| 日韩一卡二卡三卡四卡| 国产精品久久久久影院老司| 精品一区二区三区影院在线午夜| 欧美日韩视频一区二区| 亚洲精选免费视频| 99久精品国产| 一区在线观看免费| 91年精品国产| 亚洲女同ⅹxx女同tv| 91色porny在线视频| 最新成人av在线| 91丨porny丨户外露出| 亚洲视频 欧洲视频| 色综合久久综合网97色综合| 亚洲欧美一区二区三区国产精品| 96av麻豆蜜桃一区二区| 亚洲欧美另类综合偷拍| 色噜噜狠狠色综合中国| 亚洲一区二区三区影院| 欧美日韩精品一区二区三区四区| 午夜精品久久久久久久久久| 91精品国产综合久久精品性色| 日本欧美大码aⅴ在线播放| 日韩午夜激情免费电影| 精品一区精品二区高清| 久久免费午夜影院| 不卡在线观看av| 亚洲男人的天堂在线aⅴ视频| 色av成人天堂桃色av| 亚洲国产成人91porn| 欧美一区二区在线免费播放| 美女视频黄免费的久久| 婷婷综合另类小说色区| 日韩欧美中文字幕公布| 国内不卡的二区三区中文字幕| 国产亚洲自拍一区| 99精品久久只有精品| 亚洲永久免费av| 欧美一区二区福利在线| 国产精选一区二区三区| 国产精品久久久久影院老司| 欧美伊人精品成人久久综合97| 婷婷亚洲久悠悠色悠在线播放 | 成人高清视频在线| 亚洲欧美日韩成人高清在线一区| 欧美四级电影网| 久久精品国产第一区二区三区| 久久人人爽爽爽人久久久| 99精品视频一区| 午夜电影一区二区| www激情久久| 色香色香欲天天天影视综合网| 日一区二区三区| 国产校园另类小说区| 色偷偷一区二区三区| 日本少妇一区二区| 国产精品午夜久久| 在线不卡中文字幕播放| 国产91精品久久久久久久网曝门| 亚洲美女视频一区| 精品国产一区久久| 日本韩国一区二区三区| 老司机精品视频线观看86| 亚洲天堂成人网| 日韩欧美不卡在线观看视频| av在线一区二区三区| 日韩黄色免费网站| 中文子幕无线码一区tr| 欧美日韩免费在线视频| 国产精品18久久久| 午夜精品久久久久久久蜜桃app| 国产日韩成人精品| 69成人精品免费视频| 成人久久视频在线观看| 丝袜美腿成人在线| 亚洲婷婷国产精品电影人久久| 欧美一级精品大片| 在线视频欧美区| 国产乱淫av一区二区三区| 首页国产丝袜综合| 国产精品国产三级国产有无不卡 | 日韩激情在线观看| 国产精品国产三级国产aⅴ中文 | 国产亚洲精久久久久久| 欧美日韩国产一级片| 成人app网站| 激情文学综合丁香| 欧美电影在线免费观看| youjizz久久| 国产一区在线视频| 日本在线观看不卡视频| 亚洲欧美日韩一区二区三区在线观看| 欧美成人video| 欧美色图激情小说| 91免费版在线看| 成人一区二区视频| 国产一区中文字幕| 久久国产免费看| 亚洲妇女屁股眼交7| 中文字幕一区二区三区四区不卡| 26uuuu精品一区二区| 91精品国产91久久综合桃花| 91国在线观看| 91女神在线视频| eeuss鲁一区二区三区| 国产福利电影一区二区三区| 裸体歌舞表演一区二区| 天堂一区二区在线| 亚洲国产精品久久久久秋霞影院| 亚洲免费在线电影| 国产精品久久二区二区| 国产精品美女久久久久高潮| xfplay精品久久| 精品国产不卡一区二区三区| 91精品欧美综合在线观看最新| 欧美性感一区二区三区| 色婷婷久久一区二区三区麻豆| av影院午夜一区| 成人免费毛片a| 国产成人午夜99999| 国产一区视频在线看| 国精产品一区一区三区mba桃花 | 天堂午夜影视日韩欧美一区二区| 亚洲综合色成人| 亚洲国产精品天堂| 亚洲一区av在线| 亚洲精品视频在线观看网站| 国产精品理论片在线观看| 国产精品视频一二| 国产精品欧美一区二区三区| 国产精品嫩草影院com| 国产精品国产自产拍高清av王其| 国产精品久久三区| 国产精品对白交换视频| 亚洲视频免费在线观看| 中文字幕一区在线观看视频| 国产精品成人一区二区艾草| 一色桃子久久精品亚洲| 亚洲欧美日韩电影| 亚洲福利电影网| 婷婷亚洲久悠悠色悠在线播放 | 亚洲在线视频一区| 亚洲一区二区三区四区中文字幕 | 一区二区免费视频| 亚洲.国产.中文慕字在线| 日韩一区精品字幕| 精品午夜一区二区三区在线观看| 美女视频黄免费的久久| 国产综合一区二区| 从欧美一区二区三区| 99精品1区2区| 欧美日韩另类一区| 成人听书哪个软件好| 国产精品久久久久久久久动漫| 自拍偷拍亚洲欧美日韩| 亚洲精品五月天| 亚洲成人www| 国产一区欧美日韩| 成人av资源下载| 欧美三级蜜桃2在线观看| 91麻豆精品国产91久久久使用方法| 日韩欧美你懂的| 久久九九久精品国产免费直播| 国产精品第一页第二页第三页| 亚洲一区在线观看免费观看电影高清| 日产国产欧美视频一区精品| 麻豆精品视频在线| 成人精品电影在线观看| 色94色欧美sute亚洲线路二| 91精品国产乱| 国产精品区一区二区三区| 亚洲综合视频在线| 看电视剧不卡顿的网站| 成人精品视频一区二区三区 | 中文字幕va一区二区三区| 一区二区三区四区在线播放| 视频一区二区三区在线| 国产成人在线免费| 欧美揉bbbbb揉bbbbb| 精品国产乱码久久久久久牛牛| 国产精品美女久久久久高潮| 亚洲电影你懂得| 国产精品一区二区三区网站| 欧美亚洲综合一区| 久久老女人爱爱| 亚洲综合色在线| 国产精品一区二区x88av| 欧美综合在线视频| 2023国产精品| 亚洲一区二区在线免费观看视频| 久久99精品国产麻豆不卡| 99国产欧美另类久久久精品| 欧美大片在线观看| 亚洲欧美偷拍三级| 精品一区在线看| 欧美天堂一区二区三区| 国产午夜精品一区二区三区视频 | 色综合中文字幕| 精品日韩欧美一区二区|