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

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

?? dibapi.cpp

?? MFC圖像處理源代碼總集
?? 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一区二区三区免费野_久草精品视频
亚洲一区自拍偷拍| 国产欧美日韩在线视频| 一区二区三区鲁丝不卡| 色婷婷av一区二区三区软件| 亚洲精品中文在线观看| 在线看国产一区二区| 午夜视频久久久久久| 欧美一级理论片| 国产成人啪午夜精品网站男同| 欧美激情一二三区| 欧美自拍偷拍午夜视频| 婷婷成人综合网| 国产偷国产偷亚洲高清人白洁| 99久久夜色精品国产网站| 亚洲午夜久久久久久久久久久| 日韩欧美一级精品久久| 成人蜜臀av电影| 亚洲一二三区在线观看| 精品国产乱码久久久久久夜甘婷婷 | 国产色婷婷亚洲99精品小说| 粉嫩av亚洲一区二区图片| 一区二区三区在线影院| 日韩一级片网站| 成人免费的视频| 人人精品人人爱| 国产精品久久久久久亚洲伦| 9191国产精品| www.亚洲在线| 美女www一区二区| 自拍偷拍欧美激情| 日韩欧美专区在线| 色先锋久久av资源部| 黄色小说综合网站| 亚洲不卡av一区二区三区| 久久久亚洲国产美女国产盗摄| 欧美在线综合视频| 国产99精品视频| 美脚の诱脚舐め脚责91| 一区二区三区在线视频播放| 欧美成人猛片aaaaaaa| 91丨九色丨国产丨porny| 视频一区在线播放| 亚洲美腿欧美偷拍| 国产欧美精品在线观看| 日韩午夜在线影院| 欧美自拍偷拍午夜视频| av成人免费在线观看| 老汉av免费一区二区三区| 亚洲国产中文字幕| 亚洲免费在线电影| 国产精品乱码久久久久久| 精品久久久久一区| 91女厕偷拍女厕偷拍高清| 久久精品国产亚洲高清剧情介绍| 亚洲美女视频在线| 国产精品毛片久久久久久久| 日韩免费高清电影| 91精品国模一区二区三区| 欧洲视频一区二区| 99久久国产免费看| 国产91精品精华液一区二区三区 | 欧美私模裸体表演在线观看| 成人免费观看av| 国产在线精品免费av| 九九视频精品免费| 麻豆精品精品国产自在97香蕉| 日韩精品欧美成人高清一区二区| 亚洲综合色婷婷| 亚洲一级电影视频| 亚洲综合激情小说| 亚洲aⅴ怡春院| 午夜欧美2019年伦理 | 奇米影视7777精品一区二区| 亚洲一区二区在线观看视频| 亚洲精品第一国产综合野| 亚洲欧美另类久久久精品| 亚洲免费观看高清完整版在线| 国产精品国产三级国产aⅴ入口 | 综合欧美一区二区三区| 中文字幕在线一区二区三区| 国产精品国模大尺度视频| 成人欧美一区二区三区| 综合av第一页| 一区二区三区毛片| 日本中文字幕一区二区视频| 青娱乐精品视频| 国产一区二区三区av电影| 国产精品一区在线观看乱码| 粉嫩嫩av羞羞动漫久久久| 波多野结衣91| 欧美在线观看你懂的| 欧美二区三区的天堂| 精品国产一区二区三区av性色 | 亚洲女与黑人做爰| 亚洲一区精品在线| 久久国产生活片100| 粉嫩在线一区二区三区视频| 91香蕉视频在线| 在线播放欧美女士性生活| 精品国产在天天线2019| 中文字幕一区二| 五月激情综合色| 国产精品996| 欧美性欧美巨大黑白大战| 日韩精品一区二区三区三区免费| 欧美激情在线看| 亚洲妇女屁股眼交7| 精品一区二区三区在线观看| 成人免费av资源| 欧美日韩成人在线一区| 国产三级一区二区三区| 亚洲一区二区三区精品在线| 久久精品国产在热久久| 91影视在线播放| 精品人在线二区三区| 日韩美女精品在线| 久久精品久久综合| 色婷婷av一区| 久久精品亚洲麻豆av一区二区 | 香蕉加勒比综合久久| 精品一区二区三区香蕉蜜桃 | 中文字幕第一区二区| 日韩av电影免费观看高清完整版| 国产成人在线色| 在线观看中文字幕不卡| 国产亚洲短视频| 午夜国产精品一区| 97久久超碰国产精品| 日韩精品最新网址| 亚洲精选视频免费看| 国产麻豆精品视频| 777色狠狠一区二区三区| 中文字幕中文字幕在线一区 | 国内精品伊人久久久久影院对白| 日本国产一区二区| 欧美国产精品中文字幕| 亚洲国产日韩精品| 欧美日韩电影在线播放| 青青草视频一区| 午夜免费欧美电影| 懂色av一区二区三区蜜臀| 91精品国产欧美一区二区| 亚洲精品欧美激情| 国产91在线看| 久久综合久久久久88| 日本成人中文字幕| 欧美在线你懂的| 亚洲黄一区二区三区| 成人aaaa免费全部观看| 国产亚洲一区二区三区四区| 久久不见久久见免费视频1| 欧美巨大另类极品videosbest| 亚洲欧美一区二区三区国产精品| 国产v综合v亚洲欧| 久久九九久久九九| 精品一区二区三区视频在线观看 | 国产综合久久久久影院| 欧美一区二区精品在线| 天堂在线一区二区| 欧美日韩国产区一| 午夜成人在线视频| 欧美日韩一区三区| 日韩精品高清不卡| 在线综合亚洲欧美在线视频| 视频一区二区中文字幕| 欧美日韩亚洲综合在线| 午夜欧美在线一二页| 欧美久久久一区| 毛片一区二区三区| 26uuu国产在线精品一区二区| 久久精品国产第一区二区三区| 日韩欧美国产一区二区三区| 免费精品视频在线| 精品sm在线观看| 成人午夜精品一区二区三区| 国产精品久久影院| 91久久精品一区二区三区| 亚洲一区二区综合| 欧美一区二区观看视频| 国内精品伊人久久久久av影院| 久久久www成人免费无遮挡大片| 国产精品2024| 中文一区在线播放| 欧美影院精品一区| 青娱乐精品视频在线| 国产欧美一区二区在线| 一本久道久久综合中文字幕| 亚洲午夜一区二区| 亚洲精品在线免费观看视频| 国产69精品一区二区亚洲孕妇| 亚洲欧美色一区| 欧美一级生活片| 国产白丝精品91爽爽久久| 亚洲老妇xxxxxx| 日韩视频免费观看高清完整版在线观看| 精品无人码麻豆乱码1区2区| 国产欧美综合在线观看第十页| 91黄色免费版| 精品制服美女久久| 一二三区精品视频|