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

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

?? dibapi.cpp

?? matlab圖像處理的基本例程
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//  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))
	{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区视频在线播放| 欧美国产精品劲爆| 婷婷综合在线观看| 91精品国产综合久久小美女| 美脚の诱脚舐め脚责91| 精品剧情在线观看| 国产麻豆精品95视频| 欧美国产日韩一二三区| 色诱视频网站一区| 午夜精品一区二区三区三上悠亚| 91麻豆精品国产无毒不卡在线观看| 日本不卡免费在线视频| 国产午夜精品美女毛片视频| 91丝袜美女网| 日本不卡一二三区黄网| 久久免费看少妇高潮| 91亚洲精品久久久蜜桃| 午夜视频在线观看一区二区三区 | 久久久久久久精| 懂色av一区二区三区蜜臀| 亚洲精品ww久久久久久p站| 欧美日韩国产一区二区三区地区| 毛片av一区二区| 国产精品久久久爽爽爽麻豆色哟哟| 一本久久a久久精品亚洲| 国产一区二区三区久久悠悠色av| 欧美—级在线免费片| 欧美影片第一页| 国产一区二区三区四区五区入口 | 久久精品在线免费观看| 欧美性一区二区| 国产一区二区三区不卡在线观看 | 亚洲免费观看高清完整版在线| 91精品中文字幕一区二区三区| 国产精品自拍毛片| 亚洲一卡二卡三卡四卡五卡| 欧美tickling挠脚心丨vk| 色香蕉成人二区免费| 国产综合久久久久影院| 亚洲国产美女搞黄色| 久久精品在线免费观看| 欧美区视频在线观看| 成人性生交大合| 美女脱光内衣内裤视频久久网站 | 51精品视频一区二区三区| 国产电影一区在线| 日韩精品乱码av一区二区| 自拍偷拍欧美激情| 久久久久久久综合色一本| 91精品国产色综合久久不卡电影| 91网站最新网址| 国产精品中文字幕日韩精品 | 亚洲图片激情小说| 精品免费99久久| 欧美亚一区二区| av亚洲精华国产精华| 国内精品在线播放| 日本欧美加勒比视频| 一区二区三区久久| 亚洲综合清纯丝袜自拍| 亚洲天天做日日做天天谢日日欢| 久久嫩草精品久久久精品| 日韩无一区二区| 4438成人网| 欧美日韩一区二区欧美激情| 91麻豆swag| 99久久综合精品| 国产成+人+日韩+欧美+亚洲| 久久福利视频一区二区| 日韩av在线播放中文字幕| 亚洲超碰97人人做人人爱| 亚洲一区自拍偷拍| 夜夜嗨av一区二区三区中文字幕| 日韩理论片网站| 亚洲天堂免费看| 亚洲人吸女人奶水| 一区二区久久久久久| 亚洲美女淫视频| 亚洲综合一区二区精品导航| 日韩美女啊v在线免费观看| 亚洲欧洲综合另类| 亚洲欧美偷拍另类a∨色屁股| 国产精品日日摸夜夜摸av| 国产精品视频第一区| 国产精品美女视频| 最新国产の精品合集bt伙计| 亚洲欧美日韩一区二区三区在线观看| 亚洲人成亚洲人成在线观看图片| 亚洲日本免费电影| 亚洲va国产va欧美va观看| 图片区小说区区亚洲影院| 免费成人小视频| 国产福利一区二区三区视频在线| 国产精品一二三在| 91丨九色porny丨蝌蚪| 欧美色综合网站| 日韩亚洲欧美一区| 久久精品综合网| 亚洲精品va在线观看| 视频一区视频二区中文字幕| 精品一区二区影视| 成人h精品动漫一区二区三区| 91丝袜美腿高跟国产极品老师 | 国产传媒一区在线| 99精品久久99久久久久| 欧美色手机在线观看| 欧美成人三级电影在线| 国产蜜臀97一区二区三区| 亚洲黄色在线视频| 麻豆精品久久久| 99精品视频免费在线观看| 在线播放日韩导航| 欧美经典三级视频一区二区三区| 久久国产麻豆精品| 国产成人午夜片在线观看高清观看| 99久久久精品| 欧美一区二区免费| 自拍偷拍亚洲激情| 久久99久久99小草精品免视看| 成人国产精品免费观看动漫 | 日韩欧美国产一区在线观看| 国产色产综合产在线视频| 亚洲福利视频导航| 成人性生交大合| 日韩一区二区三区在线观看| 国产精品少妇自拍| 免费视频一区二区| 在线观看一区二区视频| 欧美xxxx在线观看| 亚洲超碰97人人做人人爱| 福利电影一区二区三区| 91精品国产91久久综合桃花| 中文字幕亚洲区| 国产一区二区三区最好精华液 | 在线不卡的av| 亚洲乱码精品一二三四区日韩在线| 捆绑紧缚一区二区三区视频 | 欧美久久久久久蜜桃| 亚洲视频在线一区二区| 国产在线精品不卡| 欧美酷刑日本凌虐凌虐| 亚洲日本电影在线| 国产成人av一区二区三区在线| 欧美久久久一区| 一区二区三区久久久| 99在线精品免费| 国产蜜臀av在线一区二区三区| 免费观看91视频大全| 欧美日韩免费一区二区三区视频| 亚洲天堂精品在线观看| 成人性生交大片免费看中文网站| 精品久久久久久久一区二区蜜臀| 亚洲国产婷婷综合在线精品| av一本久道久久综合久久鬼色| 久久精品人人爽人人爽| 蜜臀av一区二区三区| 欧美高清hd18日本| 亚洲国产精品自拍| 精品视频一区 二区 三区| 一区二区视频在线| 色呦呦一区二区三区| 亚洲色图欧洲色图婷婷| 99精品1区2区| 亚洲欧美激情一区二区| 91在线观看一区二区| 国产精品久久久久影视| 成人aa视频在线观看| 国产精品无遮挡| www.欧美精品一二区| 国产精品久久久久久久久图文区| 国内精品写真在线观看| 久久午夜老司机| 国产成人综合亚洲网站| 国产欧美日韩三级| 波多野结衣视频一区| **网站欧美大片在线观看| 91免费小视频| 亚洲伊人色欲综合网| 678五月天丁香亚洲综合网| 秋霞午夜av一区二区三区| 日韩女优视频免费观看| 国产精品一区二区三区网站| 国产亚洲一二三区| kk眼镜猥琐国模调教系列一区二区 | 国产真实乱偷精品视频免| 久久精品一区二区三区四区| 粉嫩av一区二区三区粉嫩| 亚洲人成网站在线| 91.xcao| 成人精品一区二区三区四区 | 亚洲一卡二卡三卡四卡五卡| 在线播放欧美女士性生活| 精品一区二区免费在线观看| 国产香蕉久久精品综合网| av网站免费线看精品| 亚洲综合一区二区三区| 91精品国产免费久久综合| 国产大陆精品国产| 亚洲亚洲人成综合网络| 精品日韩一区二区三区|