亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人亚洲精品久久久久软件| 精品不卡在线视频| 精品国产区一区| 1区2区3区国产精品| 日韩精品每日更新| 91玉足脚交白嫩脚丫在线播放| 欧美一区二区三区免费| 中文字幕一区二区三区在线不卡| 免费在线观看成人| 欧美中文字幕一区二区三区| 一本一本大道香蕉久在线精品| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美一二三四在线| 亚洲一二三四久久| 99久久99久久久精品齐齐| 精品精品国产高清a毛片牛牛| 亚洲成人综合网站| 91视频.com| 中日韩av电影| 国产精品一级在线| 久久久美女毛片| 精品在线你懂的| 日韩欧美视频在线| 蜜臀av性久久久久蜜臀aⅴ| 欧美体内she精高潮| 亚洲免费视频成人| 91免费国产视频网站| 中文字幕一区二区三区不卡| 成人一区在线观看| 国产精品久久久久永久免费观看 | 久久久99精品免费观看| 毛片av一区二区| 欧美一区二区三区在线| 男女男精品网站| 日韩免费福利电影在线观看| 热久久久久久久| 欧美一级片在线看| 久久国产乱子精品免费女| 欧美一区二区三区四区五区| 日韩国产精品91| 日韩欧美资源站| 国产精品中文字幕一区二区三区| 久久精品亚洲精品国产欧美kt∨ | 99这里都是精品| 中文字幕亚洲欧美在线不卡| 99精品欧美一区| 一区二区三区高清在线| 欧美日韩免费不卡视频一区二区三区 | 国产精品久久久久影视| 国产成人免费视频网站| 亚洲欧美在线观看| 在线观看免费视频综合| 久久国产精品无码网站| 国产午夜精品久久| 91天堂素人约啪| 日本特黄久久久高潮| 欧美精品一区二区三区在线| 国产99精品在线观看| 悠悠色在线精品| 欧美电视剧在线看免费| 国产福利精品一区| 亚洲高清中文字幕| 久久人人爽爽爽人久久久| 成人午夜激情影院| 亚洲第四色夜色| 国产亚洲精品福利| 91网站视频在线观看| 奇米在线7777在线精品| 国产精品网站一区| 91精品国产综合久久福利软件| 国产麻豆精品在线| 亚洲成a人v欧美综合天堂 | 欧美一区欧美二区| 成人a免费在线看| 日韩精品三区四区| 亚洲欧洲色图综合| 精品久久久久久久久久久久久久久久久 | 欧美性猛交xxxx乱大交退制版| 日韩国产欧美在线视频| 中日韩免费视频中文字幕| 欧美精品乱码久久久久久按摩| 国产麻豆精品在线观看| 香蕉成人伊视频在线观看| 国产欧美日韩视频在线观看| 在线播放中文一区| 色婷婷综合激情| 国产在线精品免费| 男女性色大片免费观看一区二区 | 中文字幕av一区二区三区| 欧美午夜精品理论片a级按摩| 国产乱色国产精品免费视频| 丝袜亚洲精品中文字幕一区| 亚洲视频资源在线| 国产欧美中文在线| 欧美不卡一区二区三区四区| 色婷婷一区二区| 欧美另类videos死尸| 成人国产精品免费网站| 韩国欧美一区二区| 免费美女久久99| 午夜视频一区二区三区| 一区二区高清视频在线观看| 亚洲欧洲成人自拍| 欧美激情中文字幕| 国产欧美精品区一区二区三区| 欧美一区二区三区系列电影| 欧美老肥妇做.爰bbww视频| 在线视频国内一区二区| 在线中文字幕不卡| 91农村精品一区二区在线| 不卡高清视频专区| 成人黄色a**站在线观看| 高清不卡一区二区| av福利精品导航| 北条麻妃国产九九精品视频| 成人综合婷婷国产精品久久蜜臀 | 色婷婷亚洲综合| av在线不卡观看免费观看| 成人伦理片在线| 不卡一卡二卡三乱码免费网站| 丰满少妇久久久久久久| av在线播放不卡| 99这里只有精品| 色成年激情久久综合| 91成人免费在线| 欧美日韩国产区一| 日韩精品一区在线观看| 久久婷婷国产综合精品青草| 久久美女艺术照精彩视频福利播放| 久久久久久97三级| 亚洲日本一区二区三区| 一区二区三区影院| 天堂成人国产精品一区| 奇米888四色在线精品| 国产一区二区三区| 97超碰欧美中文字幕| 欧美日韩高清一区二区| 精品国产凹凸成av人导航| 中文字幕高清不卡| 亚洲最快最全在线视频| 日本视频免费一区| 成人性生交大合| 欧美性色黄大片| 亚洲精品在线免费播放| 亚洲精品日产精品乱码不卡| 日日夜夜免费精品视频| 福利一区在线观看| 欧美日韩午夜在线| 久久先锋影音av鲁色资源网| 亚洲天堂精品视频| 日本免费新一区视频| av在线免费不卡| 欧美一区二区三区视频免费播放| 亚洲国产成人午夜在线一区| 亚洲国产精品久久人人爱蜜臀| 久久精品国产在热久久| 91麻豆免费看| 国产亚洲成aⅴ人片在线观看| 一区二区在线观看视频| 韩国成人福利片在线播放| 97se亚洲国产综合自在线| 日韩欧美亚洲一区二区| 亚洲老妇xxxxxx| 国产精品资源在线观看| 欧美精品乱人伦久久久久久| 中文字幕一区二区三区不卡在线| 蜜桃av一区二区| 色国产精品一区在线观看| 国产日产欧产精品推荐色| 日韩国产在线一| 色诱亚洲精品久久久久久| 久久久久久久久久久99999| 天堂久久一区二区三区| 在线视频亚洲一区| 国产精品伦理在线| 国产一区二区三区四| 69久久99精品久久久久婷婷| 亚洲欧美日韩中文字幕一区二区三区| 国产自产视频一区二区三区| 欧美日韩免费高清一区色橹橹| 亚洲欧洲日韩一区二区三区| 国产毛片精品国产一区二区三区| 欧美少妇bbb| 亚洲精品成人天堂一二三| 国产成a人亚洲精品| 久久久精品2019中文字幕之3| 美女视频免费一区| 91麻豆精品国产91久久久久| 夜夜嗨av一区二区三区四季av| av一区二区三区四区| 中文字幕一区二区三区在线不卡| 国产乱码一区二区三区| 亚洲精品一区二区三区四区高清| 人禽交欧美网站| 欧美成人一区二区三区片免费| 五月开心婷婷久久| 在线播放亚洲一区| 麻豆91免费观看| 一区二区三区在线视频免费 | 国产精品资源网站|