亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美高清性hdvideosex| 韩国一区二区三区| 青青草国产精品亚洲专区无| 麻豆成人久久精品二区三区小说| 国产一区啦啦啦在线观看| av色综合久久天堂av综合| 欧美日韩另类一区| 久久精品夜夜夜夜久久| 又紧又大又爽精品一区二区| 免费在线看一区| 成人国产精品免费| 91精品国产色综合久久久蜜香臀| 久久精品视频网| 亚洲午夜成aⅴ人片| 国产一区二三区好的| 在线中文字幕一区二区| 久久综合色一综合色88| 一区二区三区在线免费视频| 裸体健美xxxx欧美裸体表演| 91一区一区三区| 精品国产精品一区二区夜夜嗨| 亚洲欧美自拍偷拍| 精品影视av免费| 在线精品视频免费观看| 久久久久九九视频| www.在线欧美| 日韩一级免费观看| 亚洲最快最全在线视频| 狠狠色综合日日| 精品视频1区2区3区| 中国色在线观看另类| 亚洲国产色一区| 成人午夜电影小说| 精品少妇一区二区三区在线播放 | 免费观看成人鲁鲁鲁鲁鲁视频| 不卡视频免费播放| 精品久久久久久最新网址| 一区二区三区欧美| 成人av手机在线观看| 欧美成人官网二区| 日韩精品电影一区亚洲| 色婷婷综合久久久| 国产精品国产三级国产三级人妇| 久久精品国产99久久6| 欧美在线视频全部完| 国产精品成人一区二区三区夜夜夜| 精品一区二区日韩| 日韩欧美美女一区二区三区| 亚洲一区二区三区精品在线| 99精品在线免费| 国产精品全国免费观看高清| 国内成人免费视频| 日韩一区二区在线观看视频播放| 亚洲成人www| 91福利社在线观看| 亚洲美女免费视频| 91在线播放网址| 国产精品久久久久影院色老大 | 日韩欧美一二三区| 亚洲成人动漫精品| 欧美午夜精品一区二区蜜桃 | 欧美日韩视频在线观看一区二区三区| 国产精品国产三级国产普通话三级| 国产精品一区二区免费不卡 | 国产精品99久久久久久久vr| 精品日韩在线观看| 麻豆精品在线播放| 精品国产3级a| 色就色 综合激情| 亚洲欧美日韩国产另类专区| 97精品国产97久久久久久久久久久久| 国产精品久久久爽爽爽麻豆色哟哟 | 91福利国产精品| 综合激情成人伊人| 色婷婷综合中文久久一本| 亚洲视频在线观看三级| 色婷婷av一区二区三区软件| 亚洲色欲色欲www| 在线视频中文字幕一区二区| 一区二区三区国产| 欧美三级乱人伦电影| 婷婷亚洲久悠悠色悠在线播放| 欧美精品三级在线观看| 日本色综合中文字幕| 日韩欧美国产电影| 激情伊人五月天久久综合| 久久一区二区三区四区| 成人性生交大片免费看中文网站| 国产精品私人影院| 色综合久久久久网| 亚洲一二三四久久| 欧美一区二区美女| 经典三级视频一区| 国产拍揄自揄精品视频麻豆| 99在线精品一区二区三区| 亚洲丝袜精品丝袜在线| 欧美日韩在线播放三区四区| 久久99精品久久久久久久久久久久| 欧美精品一区二区久久婷婷| 国产精品性做久久久久久| 国产精品久久看| 欧美性色aⅴ视频一区日韩精品| 丝袜国产日韩另类美女| 精品国产网站在线观看| 99在线视频精品| 欧洲精品在线观看| 奇米影视在线99精品| 久久久亚洲国产美女国产盗摄| 99re在线视频这里只有精品| 亚洲国产视频在线| 久久久99久久| 91精品福利在线| 美女任你摸久久| 亚洲欧美在线视频观看| 7777精品伊人久久久大香线蕉经典版下载 | 国产酒店精品激情| 亚洲视频在线观看一区| 欧美一区2区视频在线观看| 国产成人综合自拍| 亚洲大型综合色站| 国产日韩欧美在线一区| 欧美性生活久久| 国产精品123区| 亚洲午夜精品17c| 国产欧美精品一区二区色综合| 精品视频免费看| 成人精品一区二区三区中文字幕| 亚洲电影一级黄| 中文字幕av资源一区| 欧美色区777第一页| 国产盗摄视频一区二区三区| 亚洲一区二区三区四区的| 久久久久青草大香线综合精品| 色吧成人激情小说| 国产精品一区二区91| 午夜久久久久久| 最新国产の精品合集bt伙计| 日韩一区二区三区电影| 91美女精品福利| 国产91富婆露脸刺激对白| 日韩电影免费在线| 亚洲三级免费观看| 久久久美女艺术照精彩视频福利播放| 色视频一区二区| 成人毛片老司机大片| 麻豆国产欧美日韩综合精品二区| 亚洲欧美日韩中文播放| 国产农村妇女毛片精品久久麻豆| 日韩三级视频在线看| 欧美日韩综合不卡| 91麻豆123| 成人高清免费观看| 久久97超碰国产精品超碰| 午夜免费欧美电影| 亚洲美女视频在线观看| 国产精品视频一区二区三区不卡| 欧美哺乳videos| 91精品国产综合久久久久| 欧洲人成人精品| 色狠狠一区二区| 91丨porny丨最新| 成人av资源站| 国产不卡在线播放| 国产一区二区三区不卡在线观看| 毛片基地黄久久久久久天堂| 午夜精品aaa| 天堂在线亚洲视频| 午夜视频在线观看一区二区三区| 亚洲在线观看免费视频| 一区二区三区免费观看| 中文字幕一区二区三区不卡在线 | 99久久免费精品高清特色大片| 国产福利91精品一区| 国产乱子轮精品视频| 韩国成人在线视频| 激情国产一区二区| 国产最新精品免费| 国产精品自拍毛片| 国产成人av一区二区三区在线观看| 国产一区二三区好的| 国产高清无密码一区二区三区| 国产又黄又大久久| 高清不卡一区二区| 丁香啪啪综合成人亚洲小说 | 亚洲免费看黄网站| 亚洲欧美日韩在线不卡| 一区二区三区不卡视频在线观看 | 欧美日韩mp4| 91精品国产91热久久久做人人| 欧美日韩国产不卡| 91精品啪在线观看国产60岁| 欧美一二三区精品| 精品福利视频一区二区三区| 久久综合九色综合欧美就去吻| 久久麻豆一区二区| 国产精品美女久久久久高潮| 亚洲欧洲www| 香蕉乱码成人久久天堂爱免费| 香蕉影视欧美成人| 精品一区二区久久久|