亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人高清伦理免费影院在线观看| 欧美三级中文字幕在线观看| 成a人片亚洲日本久久| 一本色道久久加勒比精品| 欧美日韩在线播放三区| 亚洲免费av在线| 蜜桃在线一区二区三区| 97成人超碰视| 久久嫩草精品久久久久| 天堂在线一区二区| 波多野结衣精品在线| 日韩免费高清电影| 亚洲国产精品一区二区久久 | av电影在线观看一区| 欧美群妇大交群的观看方式| 国产精品美女视频| 国产一区美女在线| 91精品国产品国语在线不卡| 亚洲三级小视频| 国产精品18久久久| 欧美一级精品在线| 亚洲国产wwwccc36天堂| 91尤物视频在线观看| 国产亚洲欧美一级| 另类欧美日韩国产在线| 欧美在线观看禁18| 亚洲男人的天堂av| 99在线精品视频| 中文字幕制服丝袜成人av| 国产麻豆91精品| 2019国产精品| 国产一级精品在线| xvideos.蜜桃一区二区| 麻豆91在线观看| 欧美一级日韩一级| 秋霞av亚洲一区二区三| 欧美午夜精品久久久久久孕妇| 日韩理论片在线| 一本久久综合亚洲鲁鲁五月天 | 精品一区二区免费在线观看| 日韩欧美第一区| 麻豆91精品91久久久的内涵| 欧美成人国产一区二区| 另类中文字幕网| 久久亚区不卡日本| 国产aⅴ精品一区二区三区色成熟| 久久网这里都是精品| 国产一区二区三区免费观看| 精品福利视频一区二区三区| 国产原创一区二区| 欧美国产日产图区| www.久久久久久久久| 亚洲日本丝袜连裤袜办公室| 日本道色综合久久| 午夜伊人狠狠久久| 欧美不卡一区二区| 懂色一区二区三区免费观看| 中文字幕在线不卡| 欧美性色黄大片| 麻豆精品在线视频| 欧美国产精品一区| 一本色道久久综合狠狠躁的推荐 | 91免费小视频| 日日夜夜一区二区| 久久尤物电影视频在线观看| 99国产精品视频免费观看| 亚洲午夜电影在线观看| 精品久久久三级丝袜| 国产91精品久久久久久久网曝门| 亚洲日本青草视频在线怡红院| 欧美日韩国产精选| 国产精品自拍av| 一区二区视频在线| 欧美大肚乱孕交hd孕妇| 91在线观看视频| 日韩成人精品视频| 国产精品久久久久久亚洲毛片| 欧美性色欧美a在线播放| 国产一区在线不卡| 一区二区三区产品免费精品久久75| 欧美一区二区三区视频| 成人黄页毛片网站| 日本欧美大码aⅴ在线播放| 久久久精品影视| 欧美午夜精品一区二区蜜桃| 国产精品一二三四五| 亚洲线精品一区二区三区八戒| 欧美精品一区二区久久久| 色欧美乱欧美15图片| 国内外精品视频| 五月婷婷久久综合| 亚洲欧洲av色图| 久久夜色精品国产噜噜av| 欧美无砖砖区免费| 国产91丝袜在线播放九色| 日韩精品电影一区亚洲| 中文字幕制服丝袜一区二区三区 | 成人av在线网| 激情欧美一区二区| 天堂va蜜桃一区二区三区| 五月天亚洲精品| 亚洲欧美国产77777| 国产日韩精品一区二区三区 | 国产精品成人免费精品自在线观看| 欧美一区在线视频| 欧美无砖砖区免费| 日本高清不卡视频| 色综合婷婷久久| 成人黄页在线观看| 懂色av一区二区三区蜜臀| 九色综合狠狠综合久久| 蜜臀av国产精品久久久久| 亚洲成人先锋电影| 亚洲综合成人网| 亚洲综合偷拍欧美一区色| 亚洲视频每日更新| 国产精品久久久久久久久动漫| xfplay精品久久| 久久久久亚洲综合| 久久人人超碰精品| 久久久久久久综合狠狠综合| 久久综合网色—综合色88| 精品日韩一区二区三区| 欧美va天堂va视频va在线| 精品国精品自拍自在线| 久久综合中文字幕| 国产欧美精品区一区二区三区 | 97精品久久久久中文字幕| 不卡的av电影| 91亚洲精品一区二区乱码| 91麻豆国产香蕉久久精品| 在线这里只有精品| 欧美人xxxx| 欧美电视剧在线看免费| 国产亚洲精品bt天堂精选| 欧美国产一区在线| 亚洲欧美色一区| 亚洲成人1区2区| 日本不卡123| 国产一区二区0| 99国产一区二区三精品乱码| 色屁屁一区二区| 欧美一区二区三区喷汁尤物| 日韩精品最新网址| 日本一区二区高清| 亚洲精品视频在线观看免费| 亚洲香肠在线观看| 精品无人码麻豆乱码1区2区| 国产精品夜夜嗨| 色婷婷久久99综合精品jk白丝 | 亚洲午夜电影在线| 久久国产生活片100| 丁香另类激情小说| 欧美色精品在线视频| 日韩欧美国产一二三区| 欧美—级在线免费片| 夜夜嗨av一区二区三区中文字幕| 日韩不卡在线观看日韩不卡视频| 极品少妇xxxx精品少妇| 99国产一区二区三精品乱码| 欧美一区二区在线播放| 亚洲国产精品t66y| 午夜av电影一区| 成人av网址在线观看| 717成人午夜免费福利电影| 国产日韩欧美精品在线| 亚洲国产精品久久一线不卡| 国产一区二区0| 欧美久久久久免费| 欧美国产精品中文字幕| 日韩av网站在线观看| 99re亚洲国产精品| 亚洲精品一区二区三区蜜桃下载| 中文字幕在线观看不卡视频| 免费在线观看成人| 欧美在线免费观看视频| 国产精品女主播av| 卡一卡二国产精品| 欧美性xxxxxxxx| 国产精品久久久久三级| 狠狠色2019综合网| 欧美裸体一区二区三区| 中文字幕一区二区三区四区| 精品一区二区三区在线观看| 欧美日韩国产一级片| 亚洲欧洲另类国产综合| 经典一区二区三区| 3atv一区二区三区| 久久91精品国产91久久小草 | 欧美撒尿777hd撒尿| 中文字幕在线不卡国产视频| 国产一区999| 精品少妇一区二区三区免费观看 | 国产伦精一区二区三区| 777欧美精品| 午夜精品福利一区二区三区av| 91视视频在线观看入口直接观看www| 久久久91精品国产一区二区精品| 美洲天堂一区二卡三卡四卡视频| 欧美美女喷水视频|