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

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

?? dibapi.cpp

?? WINXP下VC編程實現(xiàn)圖像的縮放功能!
?? 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一区二区三区免费野_久草精品视频
亚洲精品一二三| 国产精品系列在线播放| 美女mm1313爽爽久久久蜜臀| 国产夫妻精品视频| 欧美精品v国产精品v日韩精品| 久久综合给合久久狠狠狠97色69| 亚洲一区欧美一区| 国产精品白丝jk白祙喷水网站| 欧美日韩国产在线观看| 国产精品三级视频| 青青青爽久久午夜综合久久午夜| 91在线丨porny丨国产| 欧美精品一区二区三区四区 | 久久久午夜精品| 一区二区激情小说| 成人精品gif动图一区| 日韩美女在线视频| 五月天激情综合| 色狠狠综合天天综合综合| 国产亚洲综合在线| 极品瑜伽女神91| 日韩欧美国产午夜精品| 亚洲综合色噜噜狠狠| 91在线精品一区二区三区| 久久精品欧美日韩精品| 另类小说综合欧美亚洲| 91超碰这里只有精品国产| 一区二区三区日韩欧美| 91小视频在线| 国产精品传媒入口麻豆| 99综合影院在线| 国产精品久久久久天堂| 成人久久视频在线观看| 欧美激情一区三区| 成人app在线观看| 国产精品情趣视频| av资源网一区| 亚洲欧美日韩国产成人精品影院| 99久久er热在这里只有精品15| 国产精品网曝门| 波多野结衣中文字幕一区二区三区| 国产亚洲精品超碰| 成人动漫在线一区| 一区二区三区四区视频精品免费| 91成人在线精品| 五月激情丁香一区二区三区| 538prom精品视频线放| 日韩精品国产精品| 久久蜜桃香蕉精品一区二区三区| 国产精品18久久久久久久网站| 日本一区二区三区国色天香| 岛国精品一区二区| 亚洲男人的天堂在线aⅴ视频| 色偷偷久久人人79超碰人人澡 | 亚洲一区二区不卡免费| 欧美在线免费观看视频| 日韩av在线免费观看不卡| 日韩午夜在线观看视频| 国产成人精品免费视频网站| 亚洲欧洲日韩在线| 欧美三级一区二区| 国内外成人在线| 中文字幕一区二区三中文字幕| 一本到不卡免费一区二区| 五月婷婷综合激情| 久久人人97超碰com| 99久久精品情趣| 免费在线一区观看| 国产欧美日韩在线| 欧美怡红院视频| 国产做a爰片久久毛片| 国产精品黄色在线观看| 67194成人在线观看| 东方欧美亚洲色图在线| 婷婷开心激情综合| 国产精品午夜免费| 69堂国产成人免费视频| 不卡av电影在线播放| 丝瓜av网站精品一区二区| 国产视频一区在线播放| 欧美午夜精品免费| 成人国产亚洲欧美成人综合网| 日韩精品电影一区亚洲| 亚洲天堂av老司机| 精品88久久久久88久久久 | 成人国产免费视频| 日本麻豆一区二区三区视频| 中文字幕日韩精品一区| 精品少妇一区二区三区日产乱码| 91在线观看视频| 国产在线不卡一区| 午夜一区二区三区视频| 国产精品无码永久免费888| 日韩欧美中文字幕一区| 在线观看免费一区| 99riav一区二区三区| 国产一区二区三区日韩| 日本女人一区二区三区| 亚洲一区二区三区精品在线| 中文字幕一区二区三中文字幕| 久久视频一区二区| 欧美一区二区成人6969| 在线精品亚洲一区二区不卡| 成人午夜av影视| 国产麻豆午夜三级精品| 美国三级日本三级久久99| 亚洲va天堂va国产va久| 精品午夜久久福利影院| 亚洲国产视频直播| 亚洲综合激情网| 亚洲激情第一区| 亚洲黄网站在线观看| 日韩一区中文字幕| 国产精品每日更新在线播放网址| 久久精品视频免费观看| 久久久九九九九| 久久久www成人免费无遮挡大片| 日韩欧美国产综合| 精品国产乱码久久| 精品国产91乱码一区二区三区| 欧美电影免费观看高清完整版在线 | 久久精品999| 精品一区二区在线观看| 国模无码大尺度一区二区三区| 激情综合色丁香一区二区| 精久久久久久久久久久| 国产一区二区伦理| 岛国一区二区在线观看| 色综合久久综合| 欧美视频一区二区三区四区 | 69久久99精品久久久久婷婷| 欧美精品欧美精品系列| 日韩精品一区二区三区四区| 久久综合久久久久88| 中文字幕精品一区二区三区精品| 国产精品成人一区二区艾草| 亚洲欧洲综合另类在线| 亚洲小说欧美激情另类| 日av在线不卡| 国产成人精品亚洲777人妖| 97精品电影院| 欧美酷刑日本凌虐凌虐| 欧美一区二区二区| 亚洲国产精品黑人久久久| 亚洲伦在线观看| 免费在线看成人av| 丰满放荡岳乱妇91ww| 欧美在线小视频| 精品久久久久久久久久久久久久久久久| 久久新电视剧免费观看| 亚洲精品中文在线影院| 奇米色777欧美一区二区| 粉嫩绯色av一区二区在线观看| 色天天综合久久久久综合片| 欧美一区二区三区男人的天堂| 国产精品视频一二三区| 天天做天天摸天天爽国产一区| 国产一区二区三区不卡在线观看 | 久久成人免费电影| 色综合天天性综合| 久久综合九色综合97婷婷女人 | 欧美精品777| 国产欧美日韩视频在线观看| 一区二区三区 在线观看视频| 久久se精品一区二区| 一本到三区不卡视频| 久久久久97国产精华液好用吗| 亚洲高清免费视频| 国产91丝袜在线18| 日韩欧美国产综合| 亚洲国产精品久久不卡毛片| 国产精品一区一区| 欧美欧美欧美欧美| 国产精品不卡在线观看| 久88久久88久久久| 欧美日韩国产首页在线观看| 亚洲欧洲精品一区二区三区| 免费精品视频最新在线| 欧美综合一区二区| 中文字幕一区免费在线观看| 麻豆成人免费电影| 欧美理论在线播放| 1000精品久久久久久久久| 国产九色精品成人porny| 日韩一区二区视频在线观看| 一区二区三区成人在线视频| 成人激情电影免费在线观看| 欧美r级在线观看| 蜜臀av性久久久久蜜臀av麻豆| 91福利国产精品| 亚洲老妇xxxxxx| 99久久综合精品| 国产精品久久网站| 国产成人免费在线视频| 久久久久99精品国产片| 国内外成人在线视频| 精品久久久久香蕉网| 麻豆久久久久久| 3atv一区二区三区| 日韩电影一二三区|