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

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

?? dibapi.cpp

?? 脫機字符識別算法
?? 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 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产高清一区二区三区| 亚洲欧洲日产国产综合网| 国产精品久线观看视频| 男男成人高潮片免费网站| av成人动漫在线观看| 日韩视频一区二区| 亚洲午夜影视影院在线观看| 91在线一区二区| 久久久不卡网国产精品二区| 欧美aⅴ一区二区三区视频| 一本久久精品一区二区| 国产午夜精品久久久久久免费视| 日韩成人午夜精品| 一本久久精品一区二区| 国产精品福利在线播放| 国产精品一区2区| 日韩欧美一级二级| 美女视频黄免费的久久| 欧美精品久久久久久久多人混战| 亚洲精品视频自拍| av一区二区三区| 欧美精彩视频一区二区三区| 国内成人免费视频| 日韩欧美美女一区二区三区| 奇米影视7777精品一区二区| 欧美少妇一区二区| 一区二区国产盗摄色噜噜| 99国产麻豆精品| 亚洲女人的天堂| 色综合欧美在线| 一区二区三区精品在线| 色综合天天综合网天天狠天天| 国产精品久久久久久亚洲毛片| 国产成人免费网站| 国产精品情趣视频| 成人禁用看黄a在线| 亚洲日本在线看| 色天天综合久久久久综合片| 亚洲免费av高清| 欧美日韩精品一区二区| 日本不卡高清视频| 久久这里只有精品6| 丁香激情综合五月| 一区二区三区四区不卡视频| 欧美私模裸体表演在线观看| 午夜欧美一区二区三区在线播放| 欧美理论片在线| 毛片基地黄久久久久久天堂| 2021久久国产精品不只是精品| 国产成人在线视频网站| 日韩一区日韩二区| 精品视频色一区| 美女网站视频久久| 国产拍欧美日韩视频二区| thepron国产精品| 亚洲二区在线观看| 久久夜色精品一区| 91丨porny丨最新| 日韩av网站免费在线| 久久色在线观看| 91国产丝袜在线播放| 奇米亚洲午夜久久精品| 国产精品久久一卡二卡| 欧美电影影音先锋| 成人网在线免费视频| 亚洲国产另类av| 久久精品水蜜桃av综合天堂| 色综合久久久久综合体| 久久99精品国产.久久久久久| 国产偷国产偷亚洲高清人白洁| 色综合久久中文综合久久牛| 奇米色一区二区三区四区| 国产精品三级视频| 欧美一区午夜精品| 99视频一区二区| 久久精品国产秦先生| 一区二区三区中文字幕电影| 2020日本不卡一区二区视频| 欧美性受xxxx黑人xyx| 国产成人精品影视| 欧美aaa在线| 亚洲一区二区在线视频| 欧美国产一区二区| 精品福利一区二区三区免费视频| 色婷婷激情综合| 99视频一区二区三区| 捆绑紧缚一区二区三区视频| 亚洲六月丁香色婷婷综合久久| 精品国产麻豆免费人成网站| 欧美日韩你懂得| 一本久久a久久免费精品不卡| 国产福利一区二区三区在线视频| 亚洲成av人片在线观看无码| 中文字幕电影一区| 久久先锋影音av鲁色资源| 91精品国产福利| 欧美三级电影一区| 色婷婷亚洲精品| 成人av电影免费在线播放| 国产一区二区三区观看| 久久99热99| 久久精品国产秦先生| 日本vs亚洲vs韩国一区三区二区| 亚洲午夜精品久久久久久久久| 亚洲欧洲精品天堂一级 | 久久久久久夜精品精品免费| 欧美一级午夜免费电影| 欧美日韩高清在线播放| 欧美手机在线视频| 色美美综合视频| 一本一道综合狠狠老| 成人激情动漫在线观看| 成人免费精品视频| 99国产精品久久久久久久久久久| av资源网一区| 青青草原综合久久大伊人精品| 午夜国产精品影院在线观看| 丝袜美腿成人在线| 日韩av在线免费观看不卡| 日韩电影在线看| 久久精品国产999大香线蕉| 蜜臀av一级做a爰片久久| 极品尤物av久久免费看| 国产原创一区二区三区| 成人涩涩免费视频| 91视频观看免费| 欧美日韩国产综合草草| 欧美一区二区三区免费大片| 91精品国产欧美一区二区18| 日韩欧美在线一区二区三区| 欧美va天堂va视频va在线| 国产日韩亚洲欧美综合| 亚洲激情在线激情| 毛片不卡一区二区| 国产成人福利片| 色屁屁一区二区| 制服丝袜av成人在线看| 久久久91精品国产一区二区精品| 国产清纯在线一区二区www| 亚洲免费观看高清| 蜜臀久久久99精品久久久久久| 国产一区二区视频在线播放| 国产成人av一区二区三区在线| 91在线播放网址| 欧美一级欧美三级| 日本一区二区三区视频视频| 一区二区在线观看不卡| 免费成人在线观看| 99国产精品久久久| 日韩一区二区电影网| 中文一区在线播放| 手机精品视频在线观看| 国产成人丝袜美腿| 欧美精品高清视频| 欧美激情一区二区三区全黄| 亚洲第一av色| 国产99久久久国产精品免费看| 欧美在线免费观看视频| 久久新电视剧免费观看| 午夜视频在线观看一区二区三区| 国产精品自拍三区| 欧美日韩精品免费观看视频| 欧美—级在线免费片| 日本aⅴ免费视频一区二区三区| 成人精品一区二区三区中文字幕| 欧美一区二区精美| 亚洲一区二区高清| 99久久精品99国产精品| 久久伊人蜜桃av一区二区| 香蕉成人啪国产精品视频综合网| 成人深夜福利app| 久久久精品一品道一区| 蜜桃av一区二区| 欧美日韩午夜影院| 亚洲欧美日韩国产另类专区| 国产自产高清不卡| 这里只有精品视频在线观看| 一区二区三区在线视频观看| 国产99久久久国产精品潘金网站| 日韩免费在线观看| 日韩av电影免费观看高清完整版 | 99国产精品99久久久久久| 久久蜜桃av一区二区天堂| 日本中文一区二区三区| 欧美日韩一区二区三区高清| 亚洲欧美日韩成人高清在线一区| 成人性视频免费网站| 日韩欧美国产1| 日本不卡一区二区三区| 欧美人牲a欧美精品| 亚洲一二三四区| 91福利国产成人精品照片| 亚洲欧美激情在线| 91丨porny丨中文| 亚洲六月丁香色婷婷综合久久 | 国产一区欧美日韩| 精品国产一区二区精华| 国产在线精品免费| 国产欧美日韩三区| 成人国产精品免费观看视频|