亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
青椒成人免费视频| 亚洲国产精品一区二区久久恐怖片| 日韩av二区在线播放| 欧美丰满少妇xxxbbb| 免费看欧美女人艹b| 精品国产sm最大网站免费看| 国产一区二区视频在线| 欧美国产日产图区| 欧美怡红院视频| 强制捆绑调教一区二区| 久久亚洲私人国产精品va媚药| 国产一区二区三区免费在线观看 | 欧美群妇大交群的观看方式| 日韩高清在线电影| 国产亚洲综合在线| 欧美在线短视频| 蜜桃视频在线观看一区二区| 国产精品欧美综合在线| 色8久久精品久久久久久蜜| 秋霞国产午夜精品免费视频| 日本一区二区三区四区| 欧美性大战久久久| 国产制服丝袜一区| 国产精品久久久久天堂| 91精品国产一区二区| 粉嫩一区二区三区性色av| 亚洲精品免费看| 久久亚洲综合色| 欧美日韩一区成人| 福利一区二区在线| 日韩不卡免费视频| 亚洲日本电影在线| 精品少妇一区二区三区日产乱码 | 精品国产一区二区三区久久影院| 波多野结衣中文字幕一区| 日日噜噜夜夜狠狠视频欧美人 | 另类小说一区二区三区| 中文字幕中文在线不卡住| 91精品国产一区二区三区香蕉 | 亚洲亚洲精品在线观看| 久久九九久久九九| 欧美精品免费视频| 91麻豆精东视频| 久久 天天综合| 亚洲小说春色综合另类电影| 中文字幕在线观看一区| 欧美精品一区二区三区久久久 | 99re热视频精品| 另类成人小视频在线| 亚洲一区二区精品视频| 1区2区3区精品视频| 国产亚洲综合在线| 国产午夜亚洲精品羞羞网站| 激情图区综合网| 日日夜夜免费精品| 亚洲成人你懂的| 亚洲综合视频在线| 日韩美女精品在线| 国产精品热久久久久夜色精品三区| 日韩精品一区二区三区swag | 亚洲图片激情小说| 久久精品亚洲国产奇米99| 日韩精品中文字幕在线不卡尤物| 欧美私模裸体表演在线观看| 一本到三区不卡视频| av不卡免费电影| 国产91精品一区二区| 国产盗摄一区二区| 国产精品99久久久久| 国产在线看一区| 精品一区二区三区在线播放 | 亚洲国产高清不卡| 国产午夜精品久久久久久免费视 | 欧美日本一区二区在线观看| 91传媒视频在线播放| 91亚洲国产成人精品一区二区三 | 99久久精品一区二区| 成人综合婷婷国产精品久久| 国产精品99久久久久久有的能看| 国产成人在线影院| 国产成人综合视频| 不卡一区二区三区四区| 99riav一区二区三区| 在线视频一区二区三区| 欧美日韩一区二区三区在线| 欧美日韩高清一区二区三区| 欧美精品777| 日韩精品专区在线| 国产日韩欧美一区二区三区乱码| 亚洲国产精品成人久久综合一区| 国产精品麻豆久久久| 樱花草国产18久久久久| 亚洲成年人网站在线观看| 日韩和欧美的一区| 国内精品不卡在线| 99精品偷自拍| 亚洲免费资源在线播放| 国产日韩欧美综合在线| 国产精品久久久久影院亚瑟| 一区二区三区高清在线| 日本成人中文字幕在线视频 | 国产欧美精品一区二区三区四区| 国产欧美精品一区aⅴ影院| 亚洲精品中文在线观看| 日本欧美久久久久免费播放网| 国模套图日韩精品一区二区| 成人av网址在线| 欧美日韩午夜影院| 2021国产精品久久精品| 亚洲欧美在线视频观看| 日韩精品一级二级 | 欧美午夜片在线看| 精品国产一区二区三区av性色| 中文字幕一区av| 免费在线观看一区| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美一区在线视频| 最新国产の精品合集bt伙计| 奇米四色…亚洲| 91在线观看免费视频| 精品国产制服丝袜高跟| 亚洲欧美日本在线| 国产精品一区二区免费不卡| 欧美日韩在线亚洲一区蜜芽| 国产女同互慰高潮91漫画| 亚洲成年人网站在线观看| 岛国一区二区在线观看| 欧美一级夜夜爽| 国产精品久久久久久久久动漫 | 午夜影视日本亚洲欧洲精品| 极品少妇xxxx精品少妇偷拍| 欧美性色黄大片| 国产精品毛片大码女人| 久久精品免费观看| 欧美日韩国产一二三| 国产精品毛片高清在线完整版 | 国产精品污网站| 美女网站在线免费欧美精品| 91麻豆精品视频| 国产欧美精品国产国产专区| 久久99精品久久久久久久久久久久| 在线免费观看日韩欧美| 中文字幕一区二区三区在线观看| 久久精品国产第一区二区三区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 亚洲bdsm女犯bdsm网站| 91网站最新地址| 中文字幕欧美日韩一区| 韩国成人福利片在线播放| 欧美一级日韩不卡播放免费| 天堂午夜影视日韩欧美一区二区| 在线观看一区日韩| 专区另类欧美日韩| 成人少妇影院yyyy| 中文字幕巨乱亚洲| 成人av免费观看| 国产人成一区二区三区影院| 国产一区二区三区在线观看免费| 91精品国产品国语在线不卡| 免费美女久久99| 欧美本精品男人aⅴ天堂| 免费精品视频在线| 日韩欧美高清在线| 麻豆免费精品视频| 精品国精品自拍自在线| 国产乱码精品一区二区三区忘忧草 | 国产一区二区在线观看免费| 精品久久久久久综合日本欧美| 久久激情五月婷婷| 精品美女被调教视频大全网站| 久久国产精品99精品国产| 久久综合中文字幕| 成人网男人的天堂| 亚洲美女视频一区| 欧美视频日韩视频在线观看| 午夜精品在线视频一区| 欧美一级二级在线观看| 国产真实乱偷精品视频免| 欧美国产禁国产网站cc| 色婷婷亚洲精品| 日韩黄色小视频| 精品国产99国产精品| 欧美日韩欧美一区二区| 亚洲国产日韩a在线播放性色| 欧美三级日韩三级国产三级| 日韩av在线播放中文字幕| 精品国产乱码久久久久久久| 国产成人免费xxxxxxxx| 亚洲靠逼com| 91精品蜜臀在线一区尤物| 国产麻豆一精品一av一免费 | 欧美日本韩国一区| 久久精品99国产精品| 国产精品毛片无遮挡高清| 色天天综合色天天久久| 热久久国产精品| 国产精品系列在线| 91福利精品第一导航| 久久国产生活片100| 国产精品久久久久久久第一福利|