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

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

?? dibapi.cpp

?? 該程序實現了jpeg編碼。開發平臺:Window XP
?? 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一区二区三区免费野_久草精品视频
亚洲欧美一区二区久久| 久草热8精品视频在线观看| 欧美日韩的一区二区| 日韩av电影一区| 国产精品系列在线| 日韩亚洲欧美高清| 色综合久久88色综合天天| 美女在线一区二区| 一区二区三区中文在线| 国产亚洲成aⅴ人片在线观看| 色婷婷激情久久| 成人激情校园春色| 久久99国产精品久久99果冻传媒| 自拍偷拍亚洲欧美日韩| 久久亚洲一区二区三区明星换脸 | 精品国产免费视频| 91久久精品网| 成人av网站在线| 国产一区二区日韩精品| 精品一区二区三区久久久| 亚洲激情av在线| 国产精品久久久久一区二区三区| 欧美mv和日韩mv的网站| 欧美色爱综合网| 欧美性猛交一区二区三区精品| 国产一区二区不卡| 日本不卡在线视频| 亚洲黄色性网站| 一区免费观看视频| 久久久久国产精品麻豆| 日韩欧美一区二区免费| 欧美日韩一区不卡| 欧美高清www午色夜在线视频| 一本大道久久a久久综合婷婷| 成人深夜福利app| 91日韩一区二区三区| 91黄色免费看| 色婷婷精品久久二区二区蜜臀av | 9191久久久久久久久久久| 欧美大黄免费观看| 国产精品成人一区二区三区夜夜夜 | 欧美色手机在线观看| 亚洲精品在线免费观看视频| 国产精品人妖ts系列视频| 亚洲一区二区欧美日韩| 久久99精品国产.久久久久久 | 日本人妖一区二区| 国产真实乱子伦精品视频| 国产成人av一区二区三区在线| 成人黄色小视频| 欧美日韩mp4| 精品女同一区二区| 国产精品福利一区| 男人的天堂久久精品| 国产成人在线电影| 欧美日韩国产精品成人| 久久久精品2019中文字幕之3| 久久成人精品无人区| 91麻豆免费看| 国产免费观看久久| 国产一区二区在线影院| 欧美日韩在线一区二区| 亚洲美女淫视频| 成人高清av在线| 欧美人妇做爰xxxⅹ性高电影| 精品国产成人系列| 亚洲成av人片| 欧美日韩中文国产| 自拍偷拍亚洲综合| 91欧美一区二区| 国产亚洲一二三区| 国产一区二区按摩在线观看| 日韩一级精品视频在线观看| 一区二区三区不卡视频在线观看| 国产91精品久久久久久久网曝门 | 欧美一区日韩一区| 秋霞电影一区二区| 欧美xxxxxxxxx| 大白屁股一区二区视频| 亚洲国产成人tv| 色8久久人人97超碰香蕉987| 亚洲欧美国产高清| 欧洲亚洲国产日韩| 偷拍自拍另类欧美| 欧美一级高清片在线观看| 免费观看在线综合| 精品久久久久久久久久久久久久久| 日韩电影免费在线观看网站| 欧美精品久久久久久久久老牛影院| 午夜成人在线视频| 亚洲精品在线观看视频| 国产乱码精品1区2区3区| 亚洲国产精品av| 欧美三级日韩三级国产三级| 免费观看一级特黄欧美大片| 久久精品日产第一区二区三区高清版 | 在线免费观看一区| 国产美女一区二区| 国产精品成人免费在线| 欧美婷婷六月丁香综合色| 成人性生交大片免费看中文| 一区二区三区欧美久久| 日韩欧美一区二区视频| 国产寡妇亲子伦一区二区| 一区二区三区成人| 久久中文字幕电影| 国产成人在线网站| 亚洲1区2区3区视频| 久久久久久久精| 欧美精品日日鲁夜夜添| 91色乱码一区二区三区| 色视频一区二区| 丁香天五香天堂综合| 五月婷婷激情综合网| 国产欧美日韩另类一区| 在线日韩国产精品| 99久久国产综合精品色伊| 精品一区二区在线观看| 午夜精品久久久久久久99樱桃| 国产精品久久久久久久久晋中| 欧美日本一区二区在线观看| 色成年激情久久综合| 91色乱码一区二区三区| 成人高清免费在线播放| 国产成人免费9x9x人网站视频| 奇米在线7777在线精品| 天天免费综合色| 亚洲444eee在线观看| 一区二区三区精品在线| 亚洲欧美视频在线观看| 中文字幕一区二区三区不卡| 亚洲国产精品激情在线观看| 国产亚洲欧洲997久久综合 | 91免费精品国自产拍在线不卡| 国产美女主播视频一区| 国产一区二区0| av爱爱亚洲一区| 日本道色综合久久| 欧美三级电影精品| 欧美日精品一区视频| 欧美日韩在线三级| 日韩欧美中文一区二区| 久久综合成人精品亚洲另类欧美 | 国产精品久久毛片| 亚洲在线视频免费观看| 久久91精品国产91久久小草| 高清视频一区二区| 欧美亚州韩日在线看免费版国语版| 91.xcao| 亚洲视频狠狠干| 亚洲一区av在线| 国产精品综合一区二区三区| 不卡视频在线观看| 欧美一区三区二区| 国产亚洲成av人在线观看导航| 亚洲美腿欧美偷拍| 韩国一区二区三区| 欧美性大战久久久久久久| 日韩美女一区二区三区四区| 国产精品水嫩水嫩| 一区二区三区在线视频播放| 香蕉加勒比综合久久| 91在线视频网址| 精品对白一区国产伦| 亚洲成人在线网站| 91视频观看免费| 亚洲精品在线观| 秋霞影院一区二区| 欧美视频中文一区二区三区在线观看| 91精品国产综合久久福利| 欧美经典一区二区| 免费高清成人在线| 91精品国产91热久久久做人人| **欧美大码日韩| av电影一区二区| 一区视频在线播放| 99久精品国产| 一二三四社区欧美黄| 717成人午夜免费福利电影| 国产精品美女久久久久久久| 国产成a人亚洲精品| 久久久99免费| 国模冰冰炮一区二区| 日韩欧美国产小视频| 午夜精品一区在线观看| 国产99精品在线观看| 亚洲精品一区二区在线观看| 美腿丝袜亚洲综合| 欧美一区二视频| 国产在线播放一区| 亚洲精品免费电影| 欧美一卡2卡3卡4卡| 国产成人在线观看| 亚洲大型综合色站| www精品美女久久久tv| 91啪在线观看| 男男成人高潮片免费网站| 日韩一区二区三区电影| 青青青伊人色综合久久| 精品动漫一区二区三区在线观看|