亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
中文字幕欧美国产| 日本麻豆一区二区三区视频| 亚洲一级二级在线| 国产成人福利片| 欧美人狂配大交3d怪物一区 | 国内精品国产成人国产三级粉色| 国产一区欧美二区| 欧美日韩精品免费| 国产欧美一区二区精品秋霞影院| 日本va欧美va瓶| 日本精品裸体写真集在线观看 | 午夜成人免费电影| 色综合久久中文字幕| 国产欧美精品日韩区二区麻豆天美| 亚洲福利一二三区| 在线亚洲高清视频| 亚洲三级小视频| eeuss鲁片一区二区三区在线看 | 欧美日韩免费一区二区三区视频| 国产女人18毛片水真多成人如厕 | 奇米一区二区三区| 欧美日韩日日骚| 亚洲一区二区在线免费观看视频| 91性感美女视频| 成人欧美一区二区三区1314| 成人在线综合网| 国产日韩欧美不卡| 成人手机在线视频| 欧美激情一区二区三区| 国产成人av影院| 久久精品人人做| 成人精品国产福利| 亚洲欧洲无码一区二区三区| 高清beeg欧美| 国产精品水嫩水嫩| 本田岬高潮一区二区三区| 国产欧美中文在线| 成人免费观看视频| ...xxx性欧美| 日本高清不卡aⅴ免费网站| 一级做a爱片久久| 欧美唯美清纯偷拍| 日韩国产欧美在线播放| 日韩一区二区三区在线观看| 激情小说亚洲一区| 国产精品久久福利| 色婷婷精品久久二区二区蜜臀av | 欧美精品一级二级| 麻豆精品视频在线观看免费| www成人在线观看| 成人va在线观看| 亚洲综合网站在线观看| 欧美一级免费观看| 国产成人精品免费一区二区| 自拍偷拍国产精品| 欧美一级久久久久久久大片| 国产乱色国产精品免费视频| 中文字幕一区二区三区在线不卡| 色就色 综合激情| 日本不卡高清视频| 国产欧美日韩精品在线| 欧美在线色视频| 老司机精品视频在线| 国产精品伦理一区二区| 欧美日韩国产色站一区二区三区| 国产自产高清不卡| 亚洲精品菠萝久久久久久久| 日韩一区二区免费在线电影| 暴力调教一区二区三区| 天涯成人国产亚洲精品一区av| 久久亚洲私人国产精品va媚药| 91亚洲精品久久久蜜桃网站 | 色婷婷香蕉在线一区二区| 日本va欧美va精品发布| 国产亚洲欧美激情| 欧美剧在线免费观看网站| 国产成人亚洲精品青草天美| 图片区小说区国产精品视频| 国产精品色婷婷久久58| 91精品国产高清一区二区三区蜜臀 | 国产一区二区主播在线| 一区二区三区四区视频精品免费| 欧美不卡123| 欧美日韩在线播放三区四区| 国产99久久久国产精品潘金| 日本免费新一区视频| 中文字幕日本不卡| 国产亚洲精品精华液| 欧美一区二区三区播放老司机| 成人福利视频在线| 国内精品嫩模私拍在线| 日本不卡免费在线视频| 亚洲一区二区在线免费看| 国产精品国产三级国产| 久久夜色精品国产欧美乱极品| 欧美精品丝袜中出| 91国产丝袜在线播放| 成人免费福利片| 国产精品99久久不卡二区| 美国欧美日韩国产在线播放| 亚洲精品免费电影| 国产精品久久久久一区| 国产午夜精品福利| 久久久噜噜噜久噜久久综合| 日韩一二三四区| 69av一区二区三区| 欧美三电影在线| 欧美视频在线不卡| 日本久久精品电影| 色综合天天综合网天天狠天天 | 国产一区二区免费看| 奇米综合一区二区三区精品视频| 亚州成人在线电影| 午夜成人在线视频| 婷婷夜色潮精品综合在线| 午夜精品影院在线观看| 亚洲一区在线播放| 亚洲午夜一区二区三区| 午夜欧美2019年伦理| 日韩精品91亚洲二区在线观看| 图片区小说区区亚洲影院| 亚洲成a人片在线不卡一二三区 | 国产精品自拍网站| 懂色av中文一区二区三区| 岛国一区二区在线观看| aaa亚洲精品| 欧美体内she精视频| 91麻豆精品国产91久久久久久| 欧美精品丝袜久久久中文字幕| 5858s免费视频成人| 精品精品欲导航| 久久精品网站免费观看| 亚洲欧美综合网| 亚洲综合久久av| 琪琪一区二区三区| 国产成人免费视频| 91福利视频久久久久| 91精品国产综合久久久久久| 精品第一国产综合精品aⅴ| 国产精品免费久久久久| 亚洲一区二区视频| 久久国产麻豆精品| 99re亚洲国产精品| 欧美日韩亚洲综合在线| 26uuu亚洲综合色欧美| 国产精品热久久久久夜色精品三区| 亚洲欧美激情插| 激情图区综合网| 色丁香久综合在线久综合在线观看| 69久久99精品久久久久婷婷 | 日韩精品一区二区在线| 国产精品久久久一区麻豆最新章节| 一区二区三区四区中文字幕| 久久精品二区亚洲w码| 97精品视频在线观看自产线路二| 欧美日韩另类国产亚洲欧美一级| 久久久亚洲精品石原莉奈| 日韩毛片一二三区| 日韩福利视频导航| 91在线观看污| 日韩免费性生活视频播放| 夜夜爽夜夜爽精品视频| 国产一区999| 91精品福利在线| 亚洲国产电影在线观看| 看片网站欧美日韩| 欧美影院精品一区| 国产精品视频麻豆| 韩国av一区二区三区在线观看| 一本色道**综合亚洲精品蜜桃冫| 26uuu欧美| 视频一区视频二区中文字幕| 色综合中文综合网| 美女视频黄a大片欧美| 99r国产精品| 久久久久久亚洲综合影院红桃 | 国产91精品入口| 欧美zozo另类异族| 首页国产欧美日韩丝袜| 在线影院国内精品| 国产精品网友自拍| 国产精品一区专区| 日韩久久久精品| 青青草一区二区三区| 在线观看国产精品网站| 综合激情成人伊人| 成人app软件下载大全免费| 26uuu国产一区二区三区| 蜜臀精品久久久久久蜜臀| 欧美日韩小视频| 午夜影院在线观看欧美| 在线观看一区二区视频| 亚洲欧美成人一区二区三区| av亚洲精华国产精华精| 国产精品久久久久久久蜜臀 | 麻豆精品久久久| 91精品国产麻豆国产自产在线| 亚洲第一狼人社区| 欧美日韩精品综合在线| 午夜欧美电影在线观看|