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

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

?? dibapi.cpp

?? 關(guān)于圖像處理的基本程序 vc++ 256色轉(zhuǎn)灰度圖 有實(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))
	{

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成av人影院在线观看网| 一区二区三区日韩欧美| 国产精品热久久久久夜色精品三区| 中文字幕一区二区三区四区| 丝袜亚洲另类欧美综合| av在线不卡观看免费观看| 91精品久久久久久久久99蜜臂| 国产欧美日韩亚州综合| 一区二区三区四区中文字幕| 国产成人自拍网| 欧美性猛交xxxx乱大交退制版 | 亚洲伦在线观看| 久久精品欧美日韩精品 | 亚洲色图一区二区| 亚洲午夜免费视频| 日日摸夜夜添夜夜添亚洲女人| 欧美情侣在线播放| 中文字幕高清不卡| 亚洲女同ⅹxx女同tv| 91在线观看免费视频| 日韩一级免费观看| 欧美喷潮久久久xxxxx| 亚洲电影在线播放| 欧美日韩黄色影视| 麻豆国产精品777777在线| 日韩一区二区三区视频| 一二三四社区欧美黄| 欧美午夜一区二区三区 | 日韩av网站在线观看| 国内精品不卡在线| 欧美日韩国产免费| 日本中文一区二区三区| 精品国产亚洲在线| 成人的网站免费观看| 欧美顶级少妇做爰| 一区二区三区精品| 777亚洲妇女| 狠狠色丁香久久婷婷综| 国产精品国产精品国产专区不蜜| 91免费版pro下载短视频| 五月婷婷激情综合| 国产成人一区在线| 亚洲在线观看免费视频| 色欧美片视频在线观看 | 日韩高清一区二区| 国产视频一区二区三区在线观看| 99精品视频在线播放观看| 亚洲444eee在线观看| 久久天天做天天爱综合色| 99vv1com这只有精品| 日本三级韩国三级欧美三级| 久久先锋影音av鲁色资源网| 91麻豆免费在线观看| 免费观看在线综合| 国产精品久久久久久户外露出 | 国产欧美久久久精品影院| 成人午夜视频免费看| 亚洲福中文字幕伊人影院| 精品国产三级a在线观看| 色噜噜久久综合| 亚洲精品一区二区三区香蕉| 91丝袜国产在线播放| 九九视频精品免费| 一区二区三区在线观看视频| 337p日本欧洲亚洲大胆精品| 欧美日韩精品福利| www.亚洲人| 国产一区在线观看麻豆| 天天操天天色综合| 亚洲人成影院在线观看| 精品国产一区久久| 欧美一区日本一区韩国一区| 一本久道久久综合中文字幕| 国内外成人在线| 偷窥少妇高潮呻吟av久久免费| 国产欧美日韩不卡| 精品少妇一区二区三区| 欧美三级视频在线播放| 99久久夜色精品国产网站| 国产又粗又猛又爽又黄91精品| 国产精品一区二区久久不卡| 亚洲成人黄色影院| 亚洲女人****多毛耸耸8| 久久综合久久99| 日韩欧美国产系列| 91精品国产综合久久久蜜臀粉嫩 | 91麻豆精品国产自产在线观看一区| 成人18精品视频| 风间由美一区二区av101| 26uuu亚洲婷婷狠狠天堂| 在线综合+亚洲+欧美中文字幕| 欧洲国内综合视频| 91老师国产黑色丝袜在线| 成人91在线观看| 成人小视频在线| 成人a区在线观看| 成人一级黄色片| 99国产精品视频免费观看| 成人av网站免费观看| 国产不卡视频一区二区三区| 国产一区二区网址| 国产盗摄一区二区| 成人午夜私人影院| 91丨porny丨蝌蚪视频| 91一区二区三区在线播放| 91成人免费电影| 欧美亚洲综合另类| 欧美日本国产视频| 日韩精品一区二区三区中文不卡| 精品久久久久香蕉网| 久久天天做天天爱综合色| 国产亚洲美州欧州综合国| 国产精品美女视频| 亚洲自拍偷拍麻豆| 秋霞国产午夜精品免费视频| 久久精品av麻豆的观看方式| 国产精品资源站在线| 高清beeg欧美| 日本道色综合久久| 色哟哟亚洲精品| 精品视频在线免费| 日韩欧美精品在线| 精品99999| 国产欧美日本一区视频| 亚洲乱码国产乱码精品精可以看| 亚洲一区二区在线免费看| 日韩av网站在线观看| 国产精品99久久久久久有的能看 | 国产精品色哟哟| 亚洲黄一区二区三区| 日本伊人色综合网| 夫妻av一区二区| 欧美三级在线播放| 久久久91精品国产一区二区三区| 国产精品欧美久久久久无广告| 亚洲一区二区3| 国产成人精品综合在线观看| 色诱视频网站一区| 欧美精品一区视频| 亚洲韩国一区二区三区| 久久99久久久欧美国产| 99国产一区二区三精品乱码| 91精品国产综合久久小美女| 国产精品欧美综合在线| 丝瓜av网站精品一区二区| 粉嫩一区二区三区在线看| 制服丝袜亚洲色图| 中文字幕在线不卡国产视频| 日本成人在线网站| 色哟哟欧美精品| 2020日本不卡一区二区视频| 一区二区三区中文字幕电影| 久久精品理论片| 色中色一区二区| 国产欧美一区视频| 美女国产一区二区| 在线不卡免费av| 国产精品激情偷乱一区二区∴| 日韩福利电影在线| 色老综合老女人久久久| 久久久久久久电影| 免费成人深夜小野草| 欧美无砖砖区免费| 亚洲精品水蜜桃| 岛国av在线一区| 精品久久久久一区二区国产| 亚洲一区中文在线| av综合在线播放| 国产日韩欧美一区二区三区综合 | 成人精品一区二区三区四区| 欧美不卡123| 奇米亚洲午夜久久精品| 欧美在线不卡一区| 亚洲自拍欧美精品| 91老司机福利 在线| 国产精品网曝门| 成人妖精视频yjsp地址| 日韩精品一区二区三区在线观看 | 色综合久久88色综合天天免费| 精品国产乱码久久久久久久| 日韩av中文在线观看| 欧美激情一区在线| 国产一区二区精品久久99 | 欧美精品三级在线观看| 国产精品麻豆欧美日韩ww| 国产成人午夜电影网| 2014亚洲片线观看视频免费| 日本不卡免费在线视频| 欧美日韩国产精品自在自线| 亚洲午夜一区二区| 91亚洲国产成人精品一区二区三 | 高清不卡一二三区| 国产欧美一区二区精品秋霞影院| 国产精品一线二线三线精华| 久久综合成人精品亚洲另类欧美 | 91福利社在线观看| 亚洲乱码中文字幕综合| 色94色欧美sute亚洲13| 一区二区三区中文字幕| 欧美午夜精品久久久久久孕妇 |