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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? bmptofiledlg.cpp

?? 一個關(guān)于加密的例子
?? CPP
字號:
// BmptoFileDlg.cpp : implementation file
//

#include "stdafx.h"
#include "BmptoFile.h"
#include "BmptoFileDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBmptoFileDlg dialog

CBmptoFileDlg::CBmptoFileDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBmptoFileDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBmptoFileDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CBmptoFileDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBmptoFileDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBmptoFileDlg, CDialog)
	//{{AFX_MSG_MAP(CBmptoFileDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_CONVERT, OnButtonConvert)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBmptoFileDlg message handlers

BOOL CBmptoFileDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CBmptoFileDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CBmptoFileDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CBmptoFileDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CBmptoFileDlg::OnButtonConvert() 
{
	CBitmap bitmap;
	if(!bitmap.LoadBitmap(IDB_BITMAP_CONVERT))
		AfxMessageBox("Load bitmap error!");

	char* szfile;
	szfile = "bmptofile.bmp";
	HANDLE hdib = DDBToDIB(bitmap, BI_RGB, NULL);
	CFile file;
	file.Open(szfile, CFile::modeCreate | CFile::modeWrite);
	SaveDIB( hdib, file);
}


//////////////////////////////////////////////////////////////////////
//convert ddb to dib 
//CBitmap			--	your bitmap
//dwCompression		--	see BITMAPINFOHEADER
//CPalette			--	the palette of the bitmap
//return			--	handle of a dib
HANDLE CBmptoFileDlg::DDBToDIB(CBitmap &bitmap, DWORD dwCompression, CPalette* pPal)
{
	BITMAP			bm;
	BITMAPINFOHEADER	bi;
	LPBITMAPINFOHEADER 	lpbi;
	DWORD			dwlen;
	HANDLE			hdib;
	HANDLE			handle;
	HDC 			hdc;
	HPALETTE		hpal;


	ASSERT( bitmap.GetSafeHandle() );

	// the function has no arg for bitfields
	if( dwCompression == BI_BITFIELDS )
		return NULL;

	// if a palette has not been supplied use defaul palette
	hpal = (HPALETTE) pPal->GetSafeHandle();
	if (hpal==NULL)
		hpal = (HPALETTE) GetStockObject(DEFAULT_PALETTE);

	// get bitmap information
	bitmap.GetObject(sizeof(bm),(LPSTR)&bm);

	// initialize the bitmapinfoheader
	bi.biSize 			= sizeof(BITMAPINFOHEADER);
	bi.biWidth			= bm.bmWidth;
	bi.biHeight			= bm.bmHeight;
	bi.biPlanes 		= 1;
	bi.biBitCount		= bm.bmPlanes * bm.bmBitsPixel;
	bi.biCompression	= dwCompression;
	bi.biSizeImage 		= 0;
	bi.biXPelsPerMeter  = 0;
	bi.biYPelsPerMeter	= 0;
	bi.biClrUsed 		= 0;
	bi.biClrImportant 	= 0;

	// compute the size of the infoheader and the color table
	int ncolors = (1 << bi.biBitCount ); 
	if( ncolors> 256 ) 
		ncolors = 0;
	dwlen  = bi.biSize + ncolors * sizeof(RGBQUAD);

	// we need a device context to get the dib from
	hdc = ::GetDC(NULL);
	hpal = SelectPalette(hdc,hpal,FALSE);
	RealizePalette(hdc);

	// allocate enough memory to hold bitmapinfoheader and color table
	hdib = GlobalAlloc(GMEM_FIXED,dwlen);

	if (!hdib){
		SelectPalette(hdc,hpal,FALSE);
		::ReleaseDC(NULL,hdc);
		return NULL;
	}

	lpbi = (LPBITMAPINFOHEADER)hdib;

	*lpbi = bi;

	// call getdibits with a NULL lpbits param, so the device driver 
	// will calculate the bisizeimage field 
	GetDIBits(hdc, (HBITMAP)bitmap.GetSafeHandle(), 0L, (DWORD)bi.biHeight,
			(LPBYTE)NULL, (LPBITMAPINFO)lpbi, (DWORD)DIB_RGB_COLORS);

	bi = *lpbi;

	// if the driver did not fill in the bisizeimage field, then compute it
	// each scan line of the image is aligned on a dword (32bit) boundary
	if (bi.biSizeImage == 0){
		bi.biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) & ~31) / 8) 
						* bi.biHeight;

		// if a compression scheme is used the result may infact be larger
		// increase the size to account for this.
		if (dwCompression != BI_RGB)
			bi.biSizeImage = (bi.biSizeImage * 3) / 2;
	}

	// realloc the buffer so that it can hold all the bits
	dwlen += bi.biSizeImage;
	if (handle = GlobalReAlloc(hdib, dwlen, GMEM_MOVEABLE))
		hdib = handle;
	else{
		GlobalFree(hdib);

		// reselect the original palette
		SelectPalette(hdc,hpal,FALSE);
		::ReleaseDC(NULL,hdc);
		return NULL;
	}

	// get the bitmap bits
	lpbi = (LPBITMAPINFOHEADER)hdib;

	// finally get the dib
	BOOL bgotbits = GetDIBits( hdc, (HBITMAP)bitmap.GetSafeHandle(),
				0L,				// start scan line
				(DWORD)bi.biHeight,		// # of scan lines
				(LPBYTE)lpbi 			// address for bitmap bits
				+ (bi.biSize + ncolors * sizeof(RGBQUAD)),
				(LPBITMAPINFO)lpbi,		// address of bitmapinfo
				(DWORD)DIB_RGB_COLORS);		// use rgb for color table

	if( !bgotbits )
	{
		GlobalFree(hdib);
		
		SelectPalette(hdc,hpal,FALSE);
		::ReleaseDC(NULL,hdc);
		return NULL;
	}

	SelectPalette(hdc,hpal,FALSE);
	::ReleaseDC(NULL,hdc);
	return hdib;

}



BOOL CBmptoFileDlg::SaveDIB(HANDLE hDib, CFile &file)
{
	BITMAPFILEHEADER bmfHdr; // Header for Bitmap file
	LPBITMAPINFOHEADER lpBI;   // Pointer to DIB info structure
	DWORD dwDIBSize;

	if (hDib == NULL)
		return FALSE;

	/*
	 * Get a pointer to the DIB memory, the first of which contains
	 * a BITMAPINFO structure
	 */
	lpBI = (LPBITMAPINFOHEADER) ::GlobalLock((HGLOBAL) hDib);
	if (lpBI == NULL)
		return FALSE;
	if (!IS_WIN30_DIB(lpBI))
	{
		::GlobalUnlock((HGLOBAL) hDib);
		return FALSE;       // It's an other-style DIB (save not supported)
	}
	/*
	 * Fill in the fields of the file header
	 */

	/* Fill in file type (first 2 bytes must be "BM" for a bitmap) */
	bmfHdr.bfType = DIB_HEADER_MARKER;  // "BM"

	// Calculating the size of the DIB is a bit tricky (if we want to
	// do it right).  The easiest way to do this is to call GlobalSize()
	// on our global handle, but since the size of our global memory may have
	// been padded a few bytes, we may end up writing out a few too
	// many bytes to the file (which may cause problems with some apps).
	//
	// So, instead let's calculate the size manually (if we can)
	//
	// First, find size of header plus size of color table.  Since the
	// first DWORD in both BITMAPINFOHEADER and BITMAPCOREHEADER conains
	// the size of the structure, let's use this.

	dwDIBSize = *(LPDWORD)lpBI + PaletteSize((LPSTR)lpBI);  // Partial Calculation

	// Now calculate the size of the image

	if ((lpBI->biCompression == BI_RLE8) || (lpBI->biCompression == BI_RLE4))
	{
		// It's an RLE bitmap, we can't calculate size, so trust the
		// biSizeImage field

		dwDIBSize += lpBI->biSizeImage;
	}
	else
	{
		DWORD dwBmBitsSize;  // Size of Bitmap Bits only

		// It's not RLE, so size is Width (DWORD aligned) * Height

		dwBmBitsSize = WIDTHBYTES((lpBI->biWidth)*((DWORD)lpBI->biBitCount)) * lpBI->biHeight;

		dwDIBSize += dwBmBitsSize;

		// Now, since we have calculated the correct size, why don't we
		// fill in the biSizeImage field (this will fix any .BMP files which
		// have this field incorrect).

		lpBI->biSizeImage = dwBmBitsSize;
	}


	// Calculate the file size by adding the DIB size to sizeof(BITMAPFILEHEADER)

	bmfHdr.bfSize = dwDIBSize + sizeof(BITMAPFILEHEADER);
	bmfHdr.bfReserved1 = 0;
	bmfHdr.bfReserved2 = 0;

	/*
	 * Now, calculate the offset the actual bitmap bits will be in
	 * the file -- It's the Bitmap file header plus the DIB header,
	 * plus the size of the color table.
	 */
	bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpBI->biSize
											  + PaletteSize((LPSTR)lpBI);
	TRY
	{
		// Write the file header
		file.Write((LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER));
		//
		// Write the DIB header and the bits
		//
		file.WriteHuge(lpBI, dwDIBSize);
	}
	CATCH (CFileException, e)
	{
		::GlobalUnlock((HGLOBAL) hDib);
		THROW_LAST();
	}
	END_CATCH

	::GlobalUnlock((HGLOBAL) hDib);
	return TRUE;
}

DWORD CBmptoFileDlg::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));
}

WORD CBmptoFileDlg::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))
	{
		DWORD dwClrUsed;

		dwClrUsed = ((LPBITMAPINFOHEADER)lpbi)->biClrUsed;
		if (dwClrUsed != 0)
			return (WORD)dwClrUsed;
	}

	/*  Calculate the number of colors in the color table based on
	 *  the number of bits per pixel for the DIB.
	 */
	if (IS_WIN30_DIB(lpbi))
		wBitCount = ((LPBITMAPINFOHEADER)lpbi)->biBitCount;
	else
		wBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;

	/* return number of colors based on bits per pixel */
	switch (wBitCount)
	{
		case 1:
			return 2;

		case 4:
			return 16;

		case 8:
			return 256;

		default:
			return 0;
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美videossexotv100| 中文字幕中文字幕一区| 亚洲成人久久影院| 色综合久久六月婷婷中文字幕| 久久久美女艺术照精彩视频福利播放| 免费av成人在线| 欧美mv日韩mv亚洲| 国内外精品视频| 国产视频一区二区在线| 成人午夜视频免费看| 国产精品欧美久久久久无广告 | 蜜臀av性久久久久av蜜臀妖精| 欧美日韩综合在线| 日韩国产欧美在线视频| 欧美一区二区三区播放老司机| 久久综合综合久久综合| 国产婷婷精品av在线| av午夜精品一区二区三区| 国产精品剧情在线亚洲| av爱爱亚洲一区| 亚洲成av人片在线| 精品国产一区二区三区久久影院| 国产伦精品一区二区三区免费| 国产精品久久看| 欧美日韩一区小说| 国产综合色在线视频区| 中文字幕在线播放不卡一区| 欧美性大战久久久| 精品一区二区三区av| 人人狠狠综合久久亚洲| 久久久亚洲综合| 色先锋资源久久综合| 青青草成人在线观看| 国产精品网站一区| 欧美精品在线视频| 成人免费视频一区| 丝袜脚交一区二区| 国产精品美女久久久久av爽李琼 | 亚洲一区二三区| 欧美草草影院在线视频| 91视视频在线直接观看在线看网页在线看 | 日韩成人午夜电影| 国产精品国产三级国产普通话三级| 欧美三级在线视频| 成人精品小蝌蚪| 欧美aⅴ一区二区三区视频| 最新日韩av在线| 亚洲精品一线二线三线无人区| 色噜噜狠狠色综合欧洲selulu| 国产一区二区剧情av在线| 亚洲午夜私人影院| 国产精品电影院| 精品久久免费看| 精品视频色一区| 97se亚洲国产综合自在线| 韩国午夜理伦三级不卡影院| 亚洲成人av中文| 成人欧美一区二区三区白人| 欧美tickling网站挠脚心| 欧美色区777第一页| 99久久精品99国产精品| 国产精品1024| 精品综合久久久久久8888| 色偷偷88欧美精品久久久| 国产久卡久卡久卡久卡视频精品| 天天综合天天做天天综合| 亚洲欧美偷拍另类a∨色屁股| 精品国产凹凸成av人导航| 69堂成人精品免费视频| 欧美性色欧美a在线播放| av不卡免费电影| 成人免费精品视频| 国产不卡视频一区| 国产麻豆精品一区二区| 精品一区二区在线播放| 蜜桃av一区二区三区| 水野朝阳av一区二区三区| 亚洲一线二线三线视频| 一区二区三区免费网站| 综合网在线视频| 国产精品第五页| 国产精品国产三级国产aⅴ入口| 国产亚洲成年网址在线观看| 久久久久国产精品免费免费搜索| 精品免费视频.| 亚洲精品在线电影| 久久久久久9999| 欧美国产一区二区| 国产精品激情偷乱一区二区∴| 国产精品黄色在线观看| 一区在线中文字幕| 亚洲激情六月丁香| 亚洲天堂av一区| 亚洲综合激情网| 午夜精品久久久久久久99水蜜桃 | 久久精品人人做| 中文字幕第一区综合| 国产精品黄色在线观看| 亚洲精品中文在线观看| 亚洲精品日日夜夜| 日韩在线一区二区三区| 精品中文av资源站在线观看| 成人综合婷婷国产精品久久蜜臀| 成人精品gif动图一区| 一本到不卡精品视频在线观看| 欧美午夜在线观看| 欧美一区二区成人6969| 久久网站热最新地址| 亚洲欧美在线观看| 午夜精品免费在线| 国产真实乱子伦精品视频| 岛国av在线一区| 色乱码一区二区三区88| 日韩一区二区精品在线观看| 日本一区二区三区国色天香| 亚洲欧美日韩国产一区二区三区 | 亚洲欧美自拍偷拍| 午夜欧美视频在线观看| 国产麻豆精品theporn| 日本久久电影网| 日韩欧美一级二级三级久久久| 国产蜜臀97一区二区三区| 一区二区欧美精品| 久久99久久久久| 91丨porny丨国产| 日韩欧美一区中文| 亚洲手机成人高清视频| 免费观看日韩电影| 一本久久a久久精品亚洲| 91精品国产全国免费观看| 中文字幕av不卡| 婷婷综合久久一区二区三区| 国产suv精品一区二区三区| 欧美日韩在线直播| 国产精品午夜久久| 久久99久久99小草精品免视看| 欧美午夜一区二区| 中文字幕av资源一区| 激情偷乱视频一区二区三区| 欧美在线视频日韩| 中文字幕精品综合| 青草av.久久免费一区| 日本伦理一区二区| 国产精品色哟哟| 国产在线精品一区二区不卡了| 欧美午夜电影一区| 国产精品成人免费在线| 国产一区在线视频| 日韩欧美亚洲一区二区| 久久蜜桃av一区精品变态类天堂 | 丝袜脚交一区二区| 色综合av在线| 国产最新精品免费| 国产69精品久久777的优势| 国内精品久久久久影院色| 91浏览器打开| 亚洲精品亚洲人成人网| 欧美少妇一区二区| 亚洲mv大片欧洲mv大片精品| 欧美日韩国产乱码电影| 视频一区中文字幕| 欧美精品一区二区三区蜜臀| 国产自产v一区二区三区c| 久久久精品免费观看| 国产精品一二一区| 亚洲精品国产一区二区精华液| 色婷婷av一区二区三区软件| 亚洲人成影院在线观看| 色婷婷精品久久二区二区蜜臀av| 午夜精品一区二区三区电影天堂| 亚洲欧洲性图库| 91免费版在线| 亚洲欧洲精品一区二区三区不卡| 欧美午夜精品久久久久久孕妇| 午夜精品成人在线| 日韩欧美国产1| 国产精品一区一区| 一区二区三区在线播放| 欧美日韩一二三| 美国十次综合导航| 久久影音资源网| 在线视频国内一区二区| 午夜精品福利在线| 国产精品久久久久精k8| 欧洲精品在线观看| 老司机免费视频一区二区三区| 精品国产91亚洲一区二区三区婷婷| 91香蕉国产在线观看软件| 午夜精品久久久久久久久久久| 精品国产免费视频| 一本大道久久精品懂色aⅴ| 午夜精彩视频在线观看不卡| 精品日本一线二线三线不卡| 成人开心网精品视频| 免费成人你懂的| 中文字幕一区二区三区蜜月| 欧美美女bb生活片| 免费高清不卡av| 亚洲一区视频在线观看视频| 欧美α欧美αv大片|