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

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

?? dibapi.cpp

?? 《精通 vc++ 圖像編程》的源代碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
    // 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; 
} 

/************************************************************************* 
 * 
 * Function:  WriteDIBFile (HANDLE, int) 
 * 
 *  Purpose:  Writes a global chunk of DIB memory to specified file 
 * 
 *  Returns:  TRUE if success, else FALSE
 * 
 * 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. 
 * 
 *************************************************************************/ 
BOOL WriteDIBFile(HDIB hDib, HANDLE fh) 
{ 
    BITMAPFILEHEADER    bmfHdr;     // Header for Bitmap file 
    LPBITMAPINFOHEADER  lpBI;       // Pointer to DIB info structure 
    DWORD               dwDIBSize; 
    DWORD               dwWritten; 

    if (!hDib) 
        return FALSE; 

    // Get a pointer to the DIB memory, the first of which contains 
    // a BITMAPINFO structure 
 
    lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDib); 
    if (!lpBI) 
    { 
        CloseHandle(fh); 
        return FALSE; 
    } 
 
    // Check to see if we're dealing with an OS/2 DIB.  If so, don't 
    // save it because our functions aren't written to deal with these 
    // DIBs. 
 
    if (lpBI->biSize != sizeof(BITMAPINFOHEADER)) 
    { 
        GlobalUnlock(hDib); 
        CloseHandle(fh); 
        return FALSE; 
    } 
 
    // Fill in the fields of the file header 
 
    // Fill in file type (first 2 bytes must be "BM" for a bitmap) 
 
    bmfHdr.bfType = DIB_HEADER_MARKER;  // "BM" 
 
    // Calculating the size of the DIB is a bit tricky (if we want to 
    // do it right).  The easiest way to do this is to call GlobalSize() 
    // on our global handle, but since the size of our global memory may have 
    // been padded a few bytes, we may end up writing out a few too 
    // many bytes to the file (which may cause problems with some apps, 
    // like HC 3.0). 
    // 
    // So, instead let's calculate the size manually. 
    // 
    // To do this, find size of header plus size of color table.  Since the 
    // first DWORD in both BITMAPINFOHEADER and BITMAPCOREHEADER conains 
    // the size of the structure, let's use this. 
 
    // Partial Calculation 
 
    dwDIBSize = *(LPDWORD)lpBI + PaletteSize((LPBYTE)lpBI);   
 
    // Now calculate the size of the image 
 
    // It's an RLE bitmap, we can't calculate size, so trust the biSizeImage 
    // field 
 
    if ((lpBI->biCompression == BI_RLE8) || (lpBI->biCompression == BI_RLE4)) 
        dwDIBSize += lpBI->biSizeImage; 
    else 
    { 
        DWORD dwBmBitsSize;  // Size of Bitmap Bits only 
 
        // It's not RLE, so size is Width (DWORD aligned) * Height 
 
        dwBmBitsSize = WIDTHBYTES((lpBI->biWidth)*((DWORD)lpBI->biBitCount)) * 
                lpBI->biHeight; 
 
        dwDIBSize += dwBmBitsSize; 
 
        // Now, since we have calculated the correct size, why don't we 
        // fill in the biSizeImage field (this will fix any .BMP files which  
        // have this field incorrect). 
 
        lpBI->biSizeImage = dwBmBitsSize; 
    } 
 
 
    // Calculate the file size by adding the DIB size to sizeof(BITMAPFILEHEADER) 
                    
    bmfHdr.bfSize = dwDIBSize + sizeof(BITMAPFILEHEADER); 
    bmfHdr.bfReserved1 = 0; 
    bmfHdr.bfReserved2 = 0; 
 
    // Now, calculate the offset the actual bitmap bits will be in 
    // the file -- It's the Bitmap file header plus the DIB header, 
    // plus the size of the color table. 
     
    bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpBI->biSize + 
            PaletteSize((LPBYTE)lpBI); 
 
    // Write the file header 
 
    WriteFile(fh, (LPBYTE)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); 
 
    // Write the DIB header and the bits -- use local version of 
    // MyWrite, so we can write more than 32767 bytes of data 
     
    WriteFile(fh, (LPBYTE)lpBI, dwDIBSize, &dwWritten, NULL); 
 
    GlobalUnlock(hDib); 
 
    if (dwWritten == 0) 
        return FALSE; // oops, something happened in the write 
    else 
        return TRUE; // Success code 
} 
 
/************************************************************************* 
 * 
 * FindDIBBits() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpDIB      - pointer to packed-DIB memory block 
 * 
 * Return Value: 
 * 
 * LPBYTE            - pointer to the DIB bits 
 * 
 * Description: 
 * 
 * This function calculates the address of the DIB's bits and returns a 
 * pointer to the DIB bits. 
 * 
 ************************************************************************/ 
LPBYTE FindDIBBits(LPBYTE lpDIB) 
{ 
   return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB)); 
} 
 
/************************************************************************* 
 * 
 * DIBWidth() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpDIB      - pointer to packed-DIB memory block 
 * 
 * Return Value: 
 * 
 * DWORD            - width of the DIB 
 * 
 * Description: 
 * 
 * This function gets the width of the DIB from the BITMAPINFOHEADER 
 * width field if it is a Windows 3.0-style DIB or from the BITMAPCOREHEADER 
 * width field if it is an OS/2-style DIB. 
 * 
 ************************************************************************/ 
DWORD DIBWidth(LPBYTE lpDIB) 
{ 
    LPBITMAPINFOHEADER   lpbmi;  // pointer to a Win 3.0-style DIB 
    LPBITMAPCOREHEADER   lpbmc;  // pointer to an OS/2-style DIB 
 
    // point to the header (whether Win 3.0 and OS/2) 
 
    lpbmi = (LPBITMAPINFOHEADER)lpDIB; 
    lpbmc = (LPBITMAPCOREHEADER)lpDIB; 
 
    // return the DIB width if it is a Win 3.0 DIB 
 
    if (lpbmi->biSize == sizeof(BITMAPINFOHEADER)) 
        return lpbmi->biWidth; 
    else  // it is an OS/2 DIB, so return its width 
        return (DWORD)lpbmc->bcWidth; 
} 
 
DWORD DIBWidth(HDIB hDIB) 
{ 
	LPBYTE lpDIB = (LPBYTE)GlobalLock(hDIB);
	DWORD dw = DIBWidth(lpDIB);
	GlobalUnlock(hDIB);
	return dw;
} 
 
/************************************************************************* 
 * 
 * DIBHeight() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpDIB      - pointer to packed-DIB memory block 
 * 
 * Return Value: 
 * 
 * DWORD            - height of the DIB 
 * 
 * Description: 
 * 
 * This function gets the height of the DIB from the BITMAPINFOHEADER 
 * height field if it is a Windows 3.0-style DIB or from the BITMAPCOREHEADER 
 * height field if it is an OS/2-style DIB. 
 * 
 ************************************************************************/ 
DWORD DIBHeight(LPBYTE lpDIB) 
{ 
   LPBITMAPINFOHEADER   lpbmi;  // pointer to a Win 3.0-style DIB 
   LPBITMAPCOREHEADER   lpbmc;  // pointer to an OS/2-style DIB 
 
   // point to the header (whether OS/2 or Win 3.0 
 
   lpbmi = (LPBITMAPINFOHEADER)lpDIB; 
   lpbmc = (LPBITMAPCOREHEADER)lpDIB; 
 
    // return the DIB height if it is a Win 3.0 DIB 
    if (lpbmi->biSize == sizeof(BITMAPINFOHEADER)) 
        return lpbmi->biHeight; 
    else  // it is an OS/2 DIB, so return its height 
        return (DWORD)lpbmc->bcHeight; 
} 
 
DWORD DIBHeight(HDIB hDIB) 
{ 
	LPBYTE lpDIB = (LPBYTE)GlobalLock(hDIB);
	DWORD dw = DIBHeight(lpDIB);
	GlobalUnlock(hDIB);
	return dw;
} 
 
/************************************************************************* 
 * 
 * PaletteSize() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpDIB      - pointer to packed-DIB memory block 
 * 
 * Return Value: 
 * 
 * WORD             - size of the color palette of the DIB 
 * 
 * Description: 
 * 
 * This function gets the size required to store the DIB's palette by 
 * multiplying the number of colors by the size of an RGBQUAD (for a 
 * Windows 3.0-style DIB) or by the size of an RGBTRIPLE (for an OS/2- 
 * style DIB). 
 * 
 ************************************************************************/ 
WORD PaletteSize(LPBYTE lpDIB) 
{ 
    // calculate the size required by the palette 
    if (IS_WIN30_DIB (lpDIB)) 
        return (DIBNumColors(lpDIB) * sizeof(RGBQUAD)); 
    else 
        return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE)); 
} 
 
WORD PaletteSize(HDIB hDIB) 
{ 
	LPBYTE lpDIB = (LPBYTE)GlobalLock(hDIB);
	WORD wSize = PaletteSize(lpDIB);
	GlobalUnlock(hDIB);
	return wSize;
} 
 
/************************************************************************* 
 * 
 * DIBNumColors() 
 * 
 * Parameter: 
 * 
 * LPBYTE lpDIB      - pointer to packed-DIB memory block 
 * 
 * Return Value: 
 * 
 * WORD             - number of colors in the color table 
 * 
 * Description: 
 * 
 * This function calculates the number of colors in the DIB's color table 
 * by finding the bits per pixel for the DIB (whether Win3.0 or OS/2-style 
 * DIB). If bits per pixel is 1: colors=2, if 4: colors=16, if 8: colors=256, 
 * if 24, no colors in color table. 
 * 
 ************************************************************************/ 
WORD DIBNumColors(LPBYTE lpDIB) 
{ 
    WORD wBitCount;  // DIB bit count 
 
    // If this is a Windows-style DIB, the number of colors in the 
    // color table can be less than the number of bits per pixel 
    // allows for (i.e. lpbi->biClrUsed can be set to some value). 
    // If this is the case, return the appropriate value. 
     
 
    if (IS_WIN30_DIB(lpDIB)) 
    { 
        DWORD dwClrUsed; 
 
        dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed; 
        if (dwClrUsed) 
 
        return (WORD)dwClrUsed; 
    } 
 
    // Calculate the number of colors in the color table based on 
    // the number of bits per pixel for the DIB. 
     
    if (IS_WIN30_DIB(lpDIB)) 
        wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount; 
    else 
        wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount; 
 
    // return number of colors based on bits per pixel 
 
    switch (wBitCount) 
    { 
        case 1: 
            return 2; 
 
        case 4: 
            return 16; 
 
        case 8: 
            return 256; 
 
        default: 
            return 0; 
    } 
} 

WORD DIBNumColors(HDIB hDIB) 
{ 
	LPBYTE lpDIB = (LPBYTE)GlobalLock(hDIB);
	WORD wSize = DIBNumColors(lpDIB);
	GlobalUnlock(hDIB);
	return wSize;
} 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久不卡网国产精品二区| 日韩一二三区视频| 久久99日本精品| 国产精品二三区| 欧美日本一道本| 成人爽a毛片一区二区免费| 午夜成人免费视频| 亚洲同性gay激情无套| 亚洲国产婷婷综合在线精品| 久久久噜噜噜久久中文字幕色伊伊 | 欧美成人乱码一区二区三区| 99久久伊人久久99| 极品美女销魂一区二区三区| 亚洲电影第三页| 国产精品盗摄一区二区三区| 26uuu亚洲| 欧美成人午夜电影| 欧美午夜影院一区| 色伊人久久综合中文字幕| 成人妖精视频yjsp地址| 国产一区在线看| 蜜臀久久久久久久| 亚洲电影一区二区| 一区二区三区中文免费| **性色生活片久久毛片| 中文文精品字幕一区二区| 精品国产百合女同互慰| 欧美精品视频www在线观看| 欧洲精品一区二区三区在线观看| 9色porny自拍视频一区二区| 国产91在线观看| 国产激情精品久久久第一区二区| 日本欧美久久久久免费播放网| 亚洲大尺度视频在线观看| 一区二区三区在线观看国产| 亚洲日本电影在线| 亚洲男人都懂的| 1024亚洲合集| 亚洲人被黑人高潮完整版| 亚洲人吸女人奶水| 亚洲精品亚洲人成人网| 亚洲精品中文字幕在线观看| 亚洲精品美腿丝袜| 亚洲国产成人高清精品| 亚洲高清在线精品| 午夜精品免费在线| 日韩精品视频网| 麻豆久久久久久久| 国内久久婷婷综合| 国产黑丝在线一区二区三区| 成人深夜在线观看| 色综合久久久网| 国产精品国产三级国产普通话三级 | 精品国免费一区二区三区| 欧美成人激情免费网| 久久久精品tv| 中文字幕一区不卡| 一级精品视频在线观看宜春院 | 一区二区三区日韩欧美精品 | 日韩美女视频19| 亚洲1区2区3区视频| 男人的天堂亚洲一区| 精品亚洲成a人| 国产成人av资源| 91视频你懂的| 91精品欧美综合在线观看最新 | 播五月开心婷婷综合| 一本一道久久a久久精品| 欧美日韩国产精选| 精品国产乱码久久久久久图片 | 亚洲欧洲av色图| 美女视频黄久久| 亚洲一区二区三区四区在线免费观看| 欧美一区二区三区不卡| 国产麻豆91精品| 一本色道综合亚洲| 日韩三级视频在线观看| 国产精品久久久久影院亚瑟| 亚洲一区二区综合| 激情图区综合网| 色呦呦一区二区三区| 日韩精品中午字幕| 综合久久久久综合| 久久精品国产一区二区三 | 国产精品入口麻豆九色| 亚洲国产精品一区二区久久恐怖片 | 亚洲午夜一二三区视频| 日本福利一区二区| 欧美一二三在线| 亚洲欧美激情插 | 欧美激情一区二区三区不卡| 精品欧美乱码久久久久久| 欧美放荡的少妇| 91精品黄色片免费大全| 亚洲国产成人午夜在线一区| 午夜伦理一区二区| 国产一区91精品张津瑜| 欧美日韩午夜在线| 久久亚洲一区二区三区四区| 一区二区三区日韩精品| 丰满放荡岳乱妇91ww| 欧美另类久久久品| 亚洲日本在线a| 国产在线精品一区二区不卡了| 欧美性生交片4| 国产女人aaa级久久久级 | 7777精品伊人久久久大香线蕉的| 国产三级精品视频| 日本在线不卡一区| 色视频一区二区| 国产日韩高清在线| 激情小说亚洲一区| 91精品国产福利| 亚洲一区二区高清| 97se亚洲国产综合自在线观| 国产美女一区二区| 欧美一区二区观看视频| 亚洲高清免费在线| 欧美不卡在线视频| 亚洲国产毛片aaaaa无费看| 成人永久看片免费视频天堂| 欧美一级精品大片| 日韩国产在线观看一区| 在线观看一区二区精品视频| 中文字幕欧美一| 国产69精品一区二区亚洲孕妇| 欧美精品一区二区三区蜜桃视频| 免费在线欧美视频| 日韩精品综合一本久道在线视频| 日本在线观看不卡视频| 欧美二区三区的天堂| 日韩成人av影视| 91麻豆精品国产| 日本午夜精品一区二区三区电影| 91精选在线观看| 美女视频免费一区| 精品国产污污免费网站入口 | 午夜亚洲福利老司机| 欧美日精品一区视频| 精品99一区二区| 欧美一卡在线观看| 欧美性猛交xxxxxx富婆| 亚洲尤物在线视频观看| 色噜噜狠狠成人网p站| 亚洲一二三四久久| 欧美性xxxxx极品少妇| 日韩在线卡一卡二| 日韩欧美色综合| 国产永久精品大片wwwapp| 国产欧美一区二区精品性色超碰 | 精品日韩一区二区三区免费视频| 日韩精品午夜视频| 亚洲精品在线三区| 成年人国产精品| 一区二区三区精品在线| 欧美一区二区视频网站| 国产一区二区导航在线播放| 国产精品热久久久久夜色精品三区| 国产成人免费视频网站 | 亚洲一区二区三区中文字幕| 欧美精品v国产精品v日韩精品| 免费美女久久99| 久久色视频免费观看| 本田岬高潮一区二区三区| 一区二区高清免费观看影视大全 | 色综合久久久久久久久| 亚洲精品第1页| 欧美日韩免费视频| 美女任你摸久久| 国产欧美日本一区视频| 91猫先生在线| 日韩精品成人一区二区三区| 久久久国产精品不卡| 在线欧美一区二区| 久草热8精品视频在线观看| 国产精品无遮挡| 欧美日韩精品电影| 福利一区福利二区| 亚洲国产中文字幕在线视频综合| 精品欧美一区二区久久| 色88888久久久久久影院野外 | 一区二区欧美在线观看| 日韩欧美国产一区二区三区| 99re成人在线| 精品一区二区三区蜜桃| 亚洲精品中文在线| 久久久久青草大香线综合精品| 欧美午夜理伦三级在线观看| 国产精品88av| 日韩高清电影一区| 亚洲色图视频免费播放| 久久综合视频网| 欧美日韩一区二区三区视频| 麻豆精品新av中文字幕| 中文字幕精品综合| 欧美aaaaa成人免费观看视频| 色天使色偷偷av一区二区| 欧美一区二区三区婷婷月色| 成人午夜在线视频| 男女视频一区二区|