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

 
/************************************************************************* 
 * 
 * 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 
    // 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; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品捆绑美女sm三区| 亚洲伊人伊色伊影伊综合网| 日韩一区中文字幕| www.av亚洲| 国产精品久久久久影院老司| 色噜噜久久综合| 亚洲图片欧美色图| 日韩一区二区电影| 国产美女久久久久| 国产日韩欧美一区二区三区乱码| 国产成a人亚洲精| 亚洲亚洲人成综合网络| 一区二区三区在线观看网站| 7777精品伊人久久久大香线蕉完整版| 日韩影院在线观看| 中文一区在线播放| 日韩精品一区二区三区在线观看| 99久久国产综合色|国产精品| 日韩不卡免费视频| 亚洲欧美一区二区三区孕妇| 日韩一区二区在线看| 日韩免费高清视频| 国产精品久线观看视频| 综合色天天鬼久久鬼色| 亚洲精品在线一区二区| 色噜噜偷拍精品综合在线| 欧美日精品一区视频| 成人中文字幕电影| 精品一区二区久久| 亚洲综合网站在线观看| 蜜臀久久99精品久久久久宅男| 亚洲欧美日韩国产综合| 日本三级亚洲精品| 国产一区高清在线| 欧美伊人久久大香线蕉综合69| 国产高清不卡二三区| 日韩电影在线免费看| 狠狠色丁香久久婷婷综| 免费成人在线视频观看| 亚洲第一福利一区| 亚洲福利视频导航| 国产成人免费在线观看不卡| 欧美日韩精品一区二区| 欧美日韩中文字幕一区| 精品奇米国产一区二区三区| 亚洲欧美日韩国产综合| 国产久卡久卡久卡久卡视频精品| 黄色日韩网站视频| 91国偷自产一区二区使用方法| 欧美电视剧在线看免费| 又紧又大又爽精品一区二区| 亚洲女厕所小便bbb| 精品在线观看视频| 欧美日韩一本到| 日本一区二区三区国色天香 | 国产精品国模大尺度视频| 日韩电影一二三区| 日本大香伊一区二区三区| 国产日韩精品视频一区| 国产乱码字幕精品高清av| 欧美日韩电影在线| 亚洲一区二区三区中文字幕在线| 成人免费高清在线| 国产婷婷色一区二区三区四区| 久久精品日产第一区二区三区高清版| 亚洲高清免费在线| 在线观看视频一区二区欧美日韩| 欧美精品久久99久久在免费线| 日韩女优av电影| 午夜欧美大尺度福利影院在线看| 美女高潮久久久| 日韩视频一区二区三区在线播放| 午夜欧美在线一二页| 欧美日韩一区久久| 日本美女一区二区三区| 欧美一区二区三区四区视频 | 成年人国产精品| 欧美性色欧美a在线播放| 亚洲精品v日韩精品| 91久久精品网| 午夜天堂影视香蕉久久| 91精品国产综合久久蜜臀| 青青草伊人久久| 2024国产精品| 亚洲不卡av一区二区三区| 欧美亚男人的天堂| 亚洲3atv精品一区二区三区| 这里只有精品99re| 久久国产夜色精品鲁鲁99| 91视频在线观看免费| 久久久久久久电影| 人人爽香蕉精品| 久久女同精品一区二区| 国产一区二区福利| 亚洲婷婷国产精品电影人久久| av亚洲精华国产精华| 亚洲主播在线播放| 欧美一级理论片| 国产一区不卡视频| 亚洲免费在线电影| 欧美一级搡bbbb搡bbbb| 国产一本一道久久香蕉| 亚洲欧美日韩国产成人精品影院| 欧美影院一区二区三区| 麻豆精品视频在线观看| 中文字幕一区二区三区四区不卡| 在线免费av一区| 看片的网站亚洲| 日韩美女精品在线| 欧美成人官网二区| 91最新地址在线播放| 爽好久久久欧美精品| 欧美国产一区在线| 7777女厕盗摄久久久| av电影天堂一区二区在线| 亚洲成人免费视| 国产人成亚洲第一网站在线播放 | 91啪亚洲精品| 美女网站视频久久| 亚洲美女视频在线| 久久久久久久综合色一本| 精品视频一区三区九区| 国产suv精品一区二区883| 亚洲电影激情视频网站| 国产精品对白交换视频| 日韩免费高清av| 欧美日韩国产精品自在自线| 成人午夜av电影| 蜜臀av一区二区在线免费观看| 亚洲免费观看高清完整版在线观看熊| 欧美va亚洲va| 91精品国产aⅴ一区二区| 91捆绑美女网站| 国产.精品.日韩.另类.中文.在线.播放 | 91精品久久久久久久91蜜桃| 成人精品国产一区二区4080| 久久机这里只有精品| 图片区小说区区亚洲影院| 亚洲欧美一区二区三区极速播放| 久久久蜜臀国产一区二区| 日韩精品一区二区三区老鸭窝| 日本道免费精品一区二区三区| www.日韩在线| 国产成人免费视频一区| 国产高清亚洲一区| 国产福利精品导航| 国产精品77777| 国产一区二区三区观看| 青青青伊人色综合久久| 免费亚洲电影在线| 首页国产欧美日韩丝袜| 亚洲国产精品自拍| 亚洲成年人影院| 午夜精品成人在线视频| 午夜天堂影视香蕉久久| 日韩激情一二三区| 日本不卡一区二区三区 | 欧美成人综合网站| 日韩欧美中文字幕公布| 日韩午夜精品视频| 精品久久国产97色综合| 久久免费美女视频| 国产拍揄自揄精品视频麻豆| 日本一二三不卡| 国产精品二三区| 一区二区三区成人在线视频| 亚洲一区在线电影| 日韩影院精彩在线| 国产一区二区三区免费| 粉嫩av亚洲一区二区图片| 不卡电影免费在线播放一区| 色综合天天综合给合国产| 亚洲免费成人av| 香蕉av福利精品导航| 九九**精品视频免费播放| 高清beeg欧美| 欧美丝袜丝交足nylons图片| 欧美日韩国产精选| 久久精品日产第一区二区三区高清版| 中文字幕精品一区| 亚洲图片欧美综合| 国产精品香蕉一区二区三区| jlzzjlzz亚洲日本少妇| 欧美日韩一区 二区 三区 久久精品| 在线播放欧美女士性生活| 国产三区在线成人av| 亚洲综合无码一区二区| 狠狠色狠狠色综合| 91豆麻精品91久久久久久| 欧美tk—视频vk| 亚洲一区精品在线| 国产精品香蕉一区二区三区| 欧美性色黄大片| 国产嫩草影院久久久久| 图片区小说区区亚洲影院| 不卡在线观看av| 精品少妇一区二区三区日产乱码| 国产精品色一区二区三区| 国产精品视频看| 日韩成人一区二区三区在线观看|