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

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

?? dibapi.cpp

?? 該代碼為二值圖像進行細化,為學習圖像目標識別及,目標邊界細化方面很有幫助
?? 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一区二区三区免费野_久草精品视频
国产精品传媒在线| 亚洲电影一级黄| www.视频一区| 麻豆视频一区二区| 亚洲大片精品永久免费| 国产伦精品一区二区三区免费 | 日韩中文字幕1| 亚洲成av人综合在线观看| 国产黄人亚洲片| 成人av在线网站| 成人黄色一级视频| 日韩欧美二区三区| 日韩久久久精品| 亚洲最新在线观看| 亚洲va欧美va天堂v国产综合| 成人在线综合网站| 色88888久久久久久影院按摩| www.视频一区| 国产丝袜美腿一区二区三区| 国产目拍亚洲精品99久久精品| 亚洲国产高清aⅴ视频| 一区二区视频免费在线观看| 国产精品自拍在线| 91福利国产成人精品照片| 国产精品久久久久一区| 丰满白嫩尤物一区二区| 欧美亚洲国产bt| 日韩色视频在线观看| 国产日韩欧美一区二区三区综合| 麻豆国产精品一区二区三区| 在线成人免费视频| 中文一区二区在线观看| 国产麻豆一精品一av一免费| 久久久综合网站| 亚洲午夜羞羞片| 国产不卡一区视频| 国产偷v国产偷v亚洲高清| 国产成人福利片| 国产精品无遮挡| 久久66热re国产| 色婷婷狠狠综合| 久久综合国产精品| 玉足女爽爽91| 国产剧情一区二区三区| 久久综合精品国产一区二区三区| 狠狠色狠狠色合久久伊人| 欧美日韩电影一区| 中文字幕中文字幕中文字幕亚洲无线| 国产999精品久久久久久绿帽| 亚洲成人午夜电影| 在线电影欧美成精品| 久久精品二区亚洲w码| 色综合久久综合中文综合网| 一区二区三区91| 91麻豆精品国产91久久久久久| 亚洲欧美偷拍三级| 久久国产精品免费| 国产精品美女久久久久av爽李琼| 99久久伊人网影院| 欧美一区二区视频网站| 一区二区视频在线| 91麻豆精品国产91久久久使用方法| 久久精品国产一区二区| 国产人久久人人人人爽| 色av成人天堂桃色av| 麻豆免费精品视频| 国产精品久久久久久久久图文区 | 日韩一区二区电影网| 伦理电影国产精品| 国产精品欧美极品| 欧美日韩久久一区二区| 国产一区二区视频在线播放| 亚洲免费毛片网站| 精品日韩在线观看| 亚洲1区2区3区4区| 国产亚洲午夜高清国产拍精品| 色播五月激情综合网| 国产精选一区二区三区| 日韩影视精彩在线| 国产精品国产三级国产aⅴ中文| 欧美日韩国产首页在线观看| 国产酒店精品激情| 蜜臀av性久久久久蜜臀aⅴ流畅| 最近日韩中文字幕| 99精品视频免费在线观看| 三级在线观看一区二区| 国产精品乱码一区二区三区软件| 69堂成人精品免费视频| 色婷婷激情综合| 粉嫩av一区二区三区| 美女视频免费一区| 亚洲成人自拍一区| 自拍av一区二区三区| 国产无遮挡一区二区三区毛片日本| 欧美日韩一区二区不卡| 免费xxxx性欧美18vr| 精品国产凹凸成av人导航| 国产成人综合在线| 久久国产精品99精品国产| 午夜一区二区三区在线观看| 日韩一区二区三区高清免费看看 | 国产超碰在线一区| 老色鬼精品视频在线观看播放| 夜夜嗨av一区二区三区四季av| 亚洲国产精品精华液2区45| 日韩三级视频中文字幕| 欧美在线影院一区二区| 久久精品久久99精品久久| 亚洲一区二区影院| 久久免费精品国产久精品久久久久| 欧美丰满高潮xxxx喷水动漫| 欧美艳星brazzers| 欧美亚洲高清一区| 色爱区综合激月婷婷| 色诱亚洲精品久久久久久| 成人免费看的视频| proumb性欧美在线观看| bt7086福利一区国产| 成人黄色小视频在线观看| 成人黄色在线网站| 99久久精品一区二区| heyzo一本久久综合| www..com久久爱| 欧洲色大大久久| 欧美精品自拍偷拍动漫精品| 777午夜精品视频在线播放| 91精品国产综合久久小美女| 91精品国产综合久久国产大片| 欧美一卡在线观看| xvideos.蜜桃一区二区| 欧美v日韩v国产v| 久久久无码精品亚洲日韩按摩| 国产欧美视频一区二区三区| 欧美激情在线免费观看| 亚洲免费在线电影| 午夜电影网亚洲视频| 精品一区二区三区免费| 成人激情黄色小说| 欧美日韩精品一区二区| 亚洲精品福利视频网站| 日韩中文字幕91| 国产成人免费高清| 色激情天天射综合网| 91精品在线一区二区| 国产三区在线成人av| 亚洲视频电影在线| 美女在线视频一区| 成人av资源在线观看| 51精品秘密在线观看| 国产亚洲一区二区在线观看| 有坂深雪av一区二区精品| 久久成人羞羞网站| 在线欧美一区二区| 亚洲精品一线二线三线无人区| 亚洲特级片在线| 久久超级碰视频| 日本高清免费不卡视频| 亚洲精品一区二区三区福利 | 三级影片在线观看欧美日韩一区二区 | 欧美在线观看禁18| 日韩欧美aaaaaa| 亚洲免费av高清| 国产伦理精品不卡| 5566中文字幕一区二区电影| 人人精品人人爱| 91成人免费在线| 国产三级一区二区| 日本 国产 欧美色综合| 91搞黄在线观看| 国产拍揄自揄精品视频麻豆| 日本人妖一区二区| 免费成人深夜小野草| 色婷婷av久久久久久久| 中文一区在线播放| 国产一区二区三区香蕉| 7777女厕盗摄久久久| 一区二区三区中文在线观看| 国产成人h网站| 欧美xxxxxxxx| 美女任你摸久久| 337p亚洲精品色噜噜| 亚洲小少妇裸体bbw| 91麻豆精东视频| 欧美日韩国产系列| 一区二区三区精品视频| 成人涩涩免费视频| 中文在线资源观看网站视频免费不卡| 美女www一区二区| 欧美一级国产精品| 五月婷婷欧美视频| 欧美亚一区二区| 亚洲午夜久久久久久久久电影网 | 国产精品国产三级国产aⅴ中文| 激情成人综合网| 日韩视频在线永久播放| 性做久久久久久免费观看| 欧美日韩一区高清| 亚洲午夜一区二区| 在线电影国产精品| 免费观看成人鲁鲁鲁鲁鲁视频|