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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dibapi.cpp

?? 高斯平滑濾波,可以用與圖形及型號(hào)處理計(jì)算
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
//  dibapi.cpp
//
//  Source file for Device-Independent Bitmap (DIB) API.  Provides
//  the following functions:
//
//  PaintDIB()          - Painting routine for a DIB
//  CreateDIBPalette()  - Creates a palette from a DIB
//  FindDIBBits()       - Returns a pointer to the DIB bits
//  DIBWidth()          - Gets the width of the DIB
//  DIBHeight()         - Gets the height of the DIB
//  PaletteSize()       - Gets the size required to store the DIB's palette
//  DIBNumColors()      - Calculates the number of colors
//                        in the DIB's color table
//  CopyHandle()        - Makes a copy of the given global memory block
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1997 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

#include "stdafx.h"
#include "dibapi.h"
#include <io.h>
#include <errno.h>
#include <math.h>

#define DIB_HEADER_MARKER   ((WORD) ('M' << 8) | 'B')

#ifdef _MAC
#define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
#define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
void ByteSwapHeader(BITMAPFILEHEADER* bmiHeader);
void ByteSwapInfo(LPSTR lpHeader, BOOL fWin30Header);
#endif

/*************************************************************************
 *
 * PaintDIB()
 *
 * Parameters:
 *
 * HDC hDC          - DC to do output to
 *
 * LPRECT lpDCRect  - rectangle on DC to do output to
 *
 * HDIB hDIB        - handle to global memory with a DIB spec
 *                    in it followed by the DIB bits
 *
 * LPRECT lpDIBRect - rectangle of DIB to output into lpDCRect
 *
 * CPalette* pPal   - pointer to CPalette containing DIB's palette
 *
 * Return Value:
 *
 * BOOL             - TRUE if DIB was drawn, FALSE otherwise
 *
 * Description:
 *   Painting routine for a DIB.  Calls StretchDIBits() or
 *   SetDIBitsToDevice() to paint the DIB.  The DIB is
 *   output to the specified DC, at the coordinates given
 *   in lpDCRect.  The area of the DIB to be output is
 *   given by lpDIBRect.
 *
 ************************************************************************/

BOOL WINAPI PaintDIB(HDC     hDC,
					LPRECT  lpDCRect,
					HDIB    hDIB,
					LPRECT  lpDIBRect,
					CPalette* pPal)
{
	LPSTR    lpDIBHdr;            // Pointer to BITMAPINFOHEADER
	LPSTR    lpDIBBits;           // Pointer to DIB bits
	BOOL     bSuccess=FALSE;      // Success/fail flag
	HPALETTE hPal=NULL;           // Our DIB's palette
	HPALETTE hOldPal=NULL;        // Previous palette

	/* Check for valid DIB handle */
	if (hDIB == NULL)
		return FALSE;

	/* Lock down the DIB, and get a pointer to the beginning of the bit
	 *  buffer
	 */
	lpDIBHdr  = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
	lpDIBBits = ::FindDIBBits(lpDIBHdr);

	// Get the DIB's palette, then select it into DC
	if (pPal != NULL)
	{
		hPal = (HPALETTE) pPal->m_hObject;

		// Select as background since we have
		// already realized in forground if needed
		hOldPal = ::SelectPalette(hDC, hPal, TRUE);
	}

	/* Make sure to use the stretching mode best for color pictures */
	::SetStretchBltMode(hDC, COLORONCOLOR);

	/* Determine whether to call StretchDIBits() or SetDIBitsToDevice() */
	if ((RECTWIDTH(lpDCRect)  == RECTWIDTH(lpDIBRect)) &&
	   (RECTHEIGHT(lpDCRect) == RECTHEIGHT(lpDIBRect)))
		bSuccess = ::SetDIBitsToDevice(hDC,                    // hDC
								   lpDCRect->left,             // DestX
								   lpDCRect->top,              // DestY
								   RECTWIDTH(lpDCRect),        // nDestWidth
								   RECTHEIGHT(lpDCRect),       // nDestHeight
								   lpDIBRect->left,            // SrcX
								   (int)DIBHeight(lpDIBHdr) -
									  lpDIBRect->top -
									  RECTHEIGHT(lpDIBRect),   // SrcY
								   0,                          // nStartScan
								   (WORD)DIBHeight(lpDIBHdr),  // nNumScans
								   lpDIBBits,                  // lpBits
								   (LPBITMAPINFO)lpDIBHdr,     // lpBitsInfo
								   DIB_RGB_COLORS);            // wUsage
   else
	  bSuccess = ::StretchDIBits(hDC,                          // hDC
							   lpDCRect->left,                 // DestX
							   lpDCRect->top,                  // DestY
							   RECTWIDTH(lpDCRect),            // nDestWidth
							   RECTHEIGHT(lpDCRect),           // nDestHeight
							   lpDIBRect->left,                // SrcX
							   lpDIBRect->top,                 // SrcY
							   RECTWIDTH(lpDIBRect),           // wSrcWidth
							   RECTHEIGHT(lpDIBRect),          // wSrcHeight
							   lpDIBBits,                      // lpBits
							   (LPBITMAPINFO)lpDIBHdr,         // lpBitsInfo
							   DIB_RGB_COLORS,                 // wUsage
							   SRCCOPY);                       // dwROP

   ::GlobalUnlock((HGLOBAL) hDIB);

	/* Reselect old palette */
	if (hOldPal != NULL)
	{
		::SelectPalette(hDC, hOldPal, TRUE);
	}

   return bSuccess;
}

/*************************************************************************
 *
 * CreateDIBPalette()
 *
 * Parameter:
 *
 * HDIB hDIB        - specifies the DIB
 *
 * Return Value:
 *
 * HPALETTE         - specifies the palette
 *
 * Description:
 *
 * This function creates a palette from a DIB by allocating memory for the
 * logical palette, reading and storing the colors from the DIB's color table
 * into the logical palette, creating a palette from this logical palette,
 * and then returning the palette's handle. This allows the DIB to be
 * displayed using the best possible colors (important for DIBs with 256 or
 * more colors).
 *
 ************************************************************************/


BOOL WINAPI CreateDIBPalette(HDIB hDIB, CPalette* pPal)
{
	LPLOGPALETTE lpPal;      // pointer to a logical palette
	HANDLE hLogPal;          // handle to a logical palette
	HPALETTE hPal = NULL;    // handle to a palette
	int i;                   // loop index
	WORD wNumColors;         // number of colors in color table
	LPSTR lpbi;              // pointer to packed-DIB
	LPBITMAPINFO lpbmi;      // pointer to BITMAPINFO structure (Win3.0)
	LPBITMAPCOREINFO lpbmc;  // pointer to BITMAPCOREINFO structure (old)
	BOOL bWinStyleDIB;       // flag which signifies whether this is a Win3.0 DIB
	BOOL bResult = FALSE;

	/* if handle to DIB is invalid, return FALSE */

	if (hDIB == NULL)
	  return FALSE;

   lpbi = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);

   /* get pointer to BITMAPINFO (Win 3.0) */
   lpbmi = (LPBITMAPINFO)lpbi;

   /* get pointer to BITMAPCOREINFO (old 1.x) */
   lpbmc = (LPBITMAPCOREINFO)lpbi;

   /* get the number of colors in the DIB */
   wNumColors = ::DIBNumColors(lpbi);

   if (wNumColors != 0)
   {
		/* allocate memory block for logical palette */
		hLogPal = ::GlobalAlloc(GHND, sizeof(LOGPALETTE)
									+ sizeof(PALETTEENTRY)
									* wNumColors);

		/* if not enough memory, clean up and return NULL */
		if (hLogPal == 0)
		{
			::GlobalUnlock((HGLOBAL) hDIB);
			return FALSE;
		}

		lpPal = (LPLOGPALETTE) ::GlobalLock((HGLOBAL) hLogPal);

		/* set version and number of palette entries */
		lpPal->palVersion = PALVERSION;
		lpPal->palNumEntries = (WORD)wNumColors;

		/* is this a Win 3.0 DIB? */
		bWinStyleDIB = IS_WIN30_DIB(lpbi);
		for (i = 0; i < (int)wNumColors; i++)
		{
			if (bWinStyleDIB)
			{
				lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed;
				lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen;
				lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue;
				lpPal->palPalEntry[i].peFlags = 0;
			}
			else
			{
				lpPal->palPalEntry[i].peRed = lpbmc->bmciColors[i].rgbtRed;
				lpPal->palPalEntry[i].peGreen = lpbmc->bmciColors[i].rgbtGreen;
				lpPal->palPalEntry[i].peBlue = lpbmc->bmciColors[i].rgbtBlue;
				lpPal->palPalEntry[i].peFlags = 0;
			}
		}

		/* create the palette and get handle to it */
		bResult = pPal->CreatePalette(lpPal);
		::GlobalUnlock((HGLOBAL) hLogPal);
		::GlobalFree((HGLOBAL) hLogPal);
	}

	::GlobalUnlock((HGLOBAL) hDIB);

	return bResult;
}

/*************************************************************************
 *
 * FindDIBBits()
 *
 * Parameter:
 *
 * LPSTR lpbi       - pointer to packed-DIB memory block
 *
 * Return Value:
 *
 * LPSTR            - pointer to the DIB bits
 *
 * Description:
 *
 * This function calculates the address of the DIB's bits and returns a
 * pointer to the DIB bits.
 *
 ************************************************************************/


LPSTR WINAPI FindDIBBits(LPSTR lpbi)
{
	return (lpbi + *(LPDWORD)lpbi + ::PaletteSize(lpbi));
}


/*************************************************************************
 *
 * DIBWidth()
 *
 * Parameter:
 *
 * LPSTR lpbi       - 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 other-style DIB.
 *
 ************************************************************************/


DWORD WINAPI DIBWidth(LPSTR lpDIB)
{
	LPBITMAPINFOHEADER lpbmi;  // pointer to a Win 3.0-style DIB
	LPBITMAPCOREHEADER lpbmc;  // pointer to an other-style DIB

	/* point to the header (whether Win 3.0 and old) */

	lpbmi = (LPBITMAPINFOHEADER)lpDIB;
	lpbmc = (LPBITMAPCOREHEADER)lpDIB;

	/* return the DIB width if it is a Win 3.0 DIB */
	if (IS_WIN30_DIB(lpDIB))
		return lpbmi->biWidth;
	else  /* it is an other-style DIB, so return its width */
		return (DWORD)lpbmc->bcWidth;
}


/*************************************************************************
 *
 * DIBHeight()
 *
 * Parameter:
 *
 * LPSTR lpbi       - 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 other-style DIB.
 *
 ************************************************************************/


DWORD WINAPI DIBHeight(LPSTR lpDIB)
{
	LPBITMAPINFOHEADER lpbmi;  // pointer to a Win 3.0-style DIB
	LPBITMAPCOREHEADER lpbmc;  // pointer to an other-style DIB

	/* point to the header (whether old or Win 3.0 */

	lpbmi = (LPBITMAPINFOHEADER)lpDIB;
	lpbmc = (LPBITMAPCOREHEADER)lpDIB;

	/* return the DIB height if it is a Win 3.0 DIB */
	if (IS_WIN30_DIB(lpDIB))
		return lpbmi->biHeight;
	else  /* it is an other-style DIB, so return its height */
		return (DWORD)lpbmc->bcHeight;
}


/*************************************************************************
 *
 * PaletteSize()
 *
 * Parameter:
 *
 * LPSTR lpbi       - 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 other-
 * style DIB).
 *
 ************************************************************************/


WORD WINAPI PaletteSize(LPSTR lpbi)
{
   /* calculate the size required by the palette */
   if (IS_WIN30_DIB (lpbi))
	  return (WORD)(::DIBNumColors(lpbi) * sizeof(RGBQUAD));
   else
	  return (WORD)(::DIBNumColors(lpbi) * sizeof(RGBTRIPLE));
}


/*************************************************************************
 *
 * DIBNumColors()
 *
 * Parameter:
 *
 * LPSTR lpbi       - 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 other-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 WINAPI DIBNumColors(LPSTR lpbi)
{
	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(lpbi))
	{

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区在线观看你懂的| 国产精品久久久久久久久动漫| 午夜久久久影院| 欧美日韩1234| 奇米四色…亚洲| 精品国产亚洲一区二区三区在线观看 | 亚洲欧美综合网| youjizz久久| 亚洲精品老司机| 4438x成人网最大色成网站| 日韩av电影免费观看高清完整版| 欧美一区二视频| 精品一区二区影视| 国产精品视频一区二区三区不卡| 91香蕉视频黄| 免费在线看一区| 日本一区二区综合亚洲| 色综合久久久久久久| 天堂精品中文字幕在线| 日韩欧美中文字幕一区| 国产成人精品免费网站| 亚洲一线二线三线久久久| 欧美一区二区视频观看视频| 国产大片一区二区| 一区二区三区不卡视频在线观看| 91精品国产高清一区二区三区| 国内精品不卡在线| 亚洲免费在线播放| 日韩欧美一级二级三级| 成人精品视频一区| 日韩综合在线视频| 国产精品美女一区二区三区| 欧美色男人天堂| 国产999精品久久| 天天做天天摸天天爽国产一区 | 日韩精品一区二区三区蜜臀| 丁香亚洲综合激情啪啪综合| 亚洲综合色区另类av| 欧美变态凌虐bdsm| 一本久久综合亚洲鲁鲁五月天 | 日韩欧美一区二区免费| av亚洲精华国产精华| 五月天丁香久久| 国产精品亲子乱子伦xxxx裸| 91精品国产aⅴ一区二区| 成人精品免费视频| 麻豆精品一区二区三区| 亚洲黄色小说网站| 久久久99久久精品欧美| 欧美老肥妇做.爰bbww| 成人的网站免费观看| 日本91福利区| 亚洲一区免费在线观看| 国产目拍亚洲精品99久久精品| 欧美精品久久99| 91一区二区三区在线播放| 九九在线精品视频| 丝袜美腿亚洲一区二区图片| 亚洲欧美一区二区在线观看| 久久日一线二线三线suv| 7777精品伊人久久久大香线蕉最新版| 成人h版在线观看| 国产乱一区二区| 免费不卡在线视频| 福利电影一区二区| 久久精品久久精品| 天堂一区二区在线| 天天操天天综合网| 亚洲国产精品久久一线不卡| 一区二区三区精品久久久| 国产精品拍天天在线| 中文字幕乱码一区二区免费| 久久免费精品国产久精品久久久久| 日韩亚洲欧美在线| 日韩午夜电影在线观看| 8x福利精品第一导航| 欧美日韩视频一区二区| 欧美系列一区二区| 欧美午夜一区二区三区免费大片| 一本久道久久综合中文字幕| 91在线精品秘密一区二区| 99天天综合性| 色综合天天综合色综合av| 91网上在线视频| 91麻豆国产在线观看| 色偷偷成人一区二区三区91| 91免费版pro下载短视频| 99久久99久久精品免费看蜜桃 | 中文字幕第一区| 国产欧美一区二区在线| 亚洲国产高清在线| 自拍av一区二区三区| 亚洲免费观看高清完整版在线观看熊| 亚洲男同1069视频| 一区二区三区四区激情| 亚洲国产精品久久一线不卡| 视频一区欧美日韩| 精品一区二区三区欧美| 国产精品亚洲人在线观看| 国产精品一二三四五| 波波电影院一区二区三区| 色狠狠色狠狠综合| 制服丝袜中文字幕亚洲| 亚洲精品一区二区三区精华液| 欧美韩国一区二区| 亚洲欧美日韩在线不卡| 天天操天天综合网| 国产激情91久久精品导航| 99久久99久久久精品齐齐 | 欧美精品久久一区| 久久综合色婷婷| 中文字幕一区二区三区蜜月| 亚洲午夜羞羞片| 久久99精品久久久久久动态图| 国产不卡免费视频| 欧洲在线/亚洲| 久久亚洲二区三区| 一区二区三区在线影院| 免费成人深夜小野草| www.性欧美| 日韩一二三区视频| 中文字幕精品—区二区四季| 亚洲午夜免费视频| 国产成a人亚洲| 欧美老人xxxx18| 国产精品黄色在线观看| 日韩成人免费看| 99久久久免费精品国产一区二区| 宅男噜噜噜66一区二区66| 久久九九久精品国产免费直播| 亚洲一区二区高清| 国产91在线|亚洲| 欧美一级免费观看| 综合久久一区二区三区| 麻豆91在线看| 欧美视频一区二区三区四区 | 国产成人日日夜夜| 在线日韩一区二区| 国产色婷婷亚洲99精品小说| 天天操天天色综合| 91在线视频免费91| 久久久影视传媒| 男人操女人的视频在线观看欧美| 97精品视频在线观看自产线路二| 欧美精品一区二区三区在线| 亚洲线精品一区二区三区| 成人爽a毛片一区二区免费| 欧美一区二区三区视频免费| 一区二区三区免费网站| 波多野结衣亚洲一区| 久久免费国产精品| 麻豆国产精品一区二区三区| 欧美视频一区二区三区| 亚洲日韩欧美一区二区在线| 国产99久久久精品| 久久综合色天天久久综合图片| 免费观看成人鲁鲁鲁鲁鲁视频| 色琪琪一区二区三区亚洲区| 中文字幕免费一区| 国产精品亚洲综合一区在线观看| 欧美大片一区二区三区| 日韩激情视频网站| 欧美日韩国产精品成人| 依依成人综合视频| 日本精品视频一区二区| 亚洲青青青在线视频| 99久久伊人精品| 中文字幕在线观看不卡视频| 成人影视亚洲图片在线| 国产精品色在线| 成人激情综合网站| 国产精品国产三级国产有无不卡| 国产成人精品亚洲日本在线桃色| 久久久综合视频| 成人性生交大片免费看视频在线 | 制服丝袜中文字幕亚洲| 日韩精品午夜视频| 欧美一级二级在线观看| 天天影视色香欲综合网老头| 日韩一区二区精品葵司在线 | 亚洲狠狠丁香婷婷综合久久久| 99久久精品免费精品国产| 亚洲精品一卡二卡| 欧洲色大大久久| 日韩av网站免费在线| 日韩精品在线看片z| 国产精品一卡二| 国产精品传媒入口麻豆| 91传媒视频在线播放| 亚洲成人精品一区| 日韩欧美黄色影院| 国产精品99久久久| **性色生活片久久毛片| 欧美亚洲高清一区二区三区不卡| 天天射综合影视| 久久精品无码一区二区三区| 成人av影视在线观看| 亚洲成人激情社区| 精品国产91乱码一区二区三区 | 久久精品夜色噜噜亚洲a∨|