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

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

?? dibapi.cpp

?? Visual C++、Matlab圖像處理與識(shí)別實(shí)用案例精選
?? 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))
	{

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆精品视频在线观看视频| 欧美精选午夜久久久乱码6080| 亚洲免费av网站| 欧美日韩国产一级| 国产高清精品网站| 亚洲v精品v日韩v欧美v专区| 国产日韩亚洲欧美综合| 欧美日韩日本视频| 99精品久久久久久| 国产自产2019最新不卡| 一区二区三区欧美日韩| 国产欧美一区二区精品性| 777久久久精品| 色婷婷激情综合| 国产成人免费在线视频| 免费成人av在线| 日韩在线观看一区二区| 亚洲品质自拍视频网站| 日本一区二区三区视频视频| 337p亚洲精品色噜噜| 在线视频国内自拍亚洲视频| 处破女av一区二区| 国产伦理精品不卡| 成人国产在线观看| 成人av网站在线观看免费| 久久综合狠狠综合久久综合88 | 日本亚洲视频在线| 一二三四社区欧美黄| 国产精品色一区二区三区| 精品国产一区a| 日韩一区二区三| 欧美一卡2卡三卡4卡5免费| 在线亚洲一区二区| 一本到三区不卡视频| 成人h动漫精品一区二| 国产69精品一区二区亚洲孕妇| 老司机精品视频线观看86| 日本中文字幕一区二区视频 | 91久久精品国产91性色tv | 丝袜亚洲另类欧美综合| 91久久国产最好的精华液| 国产剧情一区二区| 国产麻豆精品在线观看| 国产一二精品视频| 偷拍亚洲欧洲综合| 亚洲第一综合色| 亚洲小说欧美激情另类| 亚洲婷婷在线视频| 最新中文字幕一区二区三区 | 一本色道久久综合亚洲91| 色综合久久天天| 在线观看欧美黄色| 欧美人动与zoxxxx乱| 91精品国产乱| 精品久久久久久最新网址| 久久综合九色综合97_久久久| 国产女主播在线一区二区| 国产精品每日更新在线播放网址| 国产精品国产自产拍在线| 亚洲欧美日韩国产成人精品影院| 亚洲免费高清视频在线| 亚洲国产成人porn| 午夜精品爽啪视频| 精品夜夜嗨av一区二区三区| 国产传媒欧美日韩成人| 色婷婷精品久久二区二区蜜臂av | 91网上在线视频| 色哦色哦哦色天天综合| 欧美精品在欧美一区二区少妇| 91精品蜜臀在线一区尤物| xnxx国产精品| 亚洲人成小说网站色在线| 亚洲国产精品麻豆| 国产永久精品大片wwwapp| 不卡av在线免费观看| 日本久久电影网| 日韩欧美一级二级| 国产精品午夜在线观看| 亚洲高清免费视频| 国产精品综合一区二区| 91行情网站电视在线观看高清版| 欧美一区二区三区日韩视频| 国产精品日日摸夜夜摸av| 午夜欧美电影在线观看| 国产精品自拍毛片| 欧洲中文字幕精品| 久久亚洲精华国产精华液| 亚洲精品水蜜桃| 国内欧美视频一区二区| 欧美在线视频日韩| 久久免费精品国产久精品久久久久| 18欧美亚洲精品| 久久99久久99| 欧美性生活影院| 欧美国产一区二区| 蜜桃av一区二区三区电影| 91麻豆高清视频| 精品欧美一区二区三区精品久久| 亚洲精品视频在线看| 国产乱码精品一区二区三区忘忧草| 欧美无砖专区一中文字| 国产精品久久久久精k8| 久久99精品久久久久久动态图 | 久久99久久精品| 欧美亚洲自拍偷拍| 国产精品国产成人国产三级| 久草中文综合在线| 欧美精品丝袜久久久中文字幕| 国产精品夫妻自拍| 极品瑜伽女神91| 7777女厕盗摄久久久| 亚洲欧美日韩综合aⅴ视频| 国产精品99久久久久久久vr| 91精品国产综合久久久蜜臀粉嫩| 亚洲免费在线看| 成人av电影在线网| 日本一区二区三区四区 | 成人深夜视频在线观看| 日韩精品一区二区三区三区免费| 亚洲一二三四久久| 97久久人人超碰| 中文字幕免费在线观看视频一区| 国产一区二区精品在线观看| 日韩欧美亚洲国产另类| 天天操天天干天天综合网| 欧美性大战久久久| 亚洲国产婷婷综合在线精品| av高清不卡在线| 中文字幕日韩av资源站| 成人一区在线看| 国产精品污www在线观看| 国产美女一区二区三区| 久久综合久久综合九色| 狠狠色丁香婷婷综合| 日韩精品在线看片z| 久久精品国产亚洲一区二区三区| 欧美高清激情brazzers| 日韩电影网1区2区| 日韩一级黄色大片| 久久精品久久综合| 精品国产一区二区三区不卡 | 99久久久精品免费观看国产蜜| 国产欧美中文在线| 成人激情av网| 亚洲欧美乱综合| 欧美色区777第一页| 亚洲成在人线在线播放| 欧美精品高清视频| 麻豆成人久久精品二区三区红| 精品国产亚洲在线| 国产精品一色哟哟哟| 欧美一区二区三区在线| 日日骚欧美日韩| 日韩一区二区三区电影在线观看| 美女视频免费一区| 久久久国际精品| jizz一区二区| 亚洲一区二区欧美激情| 91精品在线免费观看| 麻豆一区二区99久久久久| 日韩免费视频一区| 国产·精品毛片| 亚洲精品第一国产综合野| 欧美精品v国产精品v日韩精品| 美女www一区二区| 国产精品色婷婷| 欧美伊人精品成人久久综合97| 理论电影国产精品| 国产精品欧美一区二区三区| 欧美羞羞免费网站| 精品制服美女丁香| 亚洲人成网站在线| 欧美精品第1页| 免费观看成人av| 国产精品不卡在线观看| 欧美高清视频www夜色资源网| 国产一区二区0| 一级中文字幕一区二区| 欧美大片在线观看| 色先锋资源久久综合| 男女激情视频一区| 亚洲色图都市小说| 日韩欧美视频一区| 色综合色综合色综合色综合色综合| 视频一区欧美精品| 国产精品国产自产拍高清av | 菠萝蜜视频在线观看一区| 亚洲国产一区二区a毛片| 国产免费久久精品| 日韩一区二区三区精品视频 | 精品国产污网站| 亚洲欧美一区二区久久| 日韩欧美一区中文| 色婷婷香蕉在线一区二区| 国产又粗又猛又爽又黄91精品| 亚洲mv大片欧洲mv大片精品| 久久精品视频在线看| 在线亚洲欧美专区二区| 国产精品一区一区三区| 婷婷久久综合九色国产成人|