⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmpshow.cpp

📁 基于SAA7113的MPEG-4程序
💻 CPP
字号:
// BmpShow.cpp: implementation of the CBmpShow class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MonClient.h"
#include "BmpShow.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBmpShow* CBmpShow::m_sInstance=0;

CBmpShow::CBmpShow()
{

}

CBmpShow::~CBmpShow()
{

}


CBmpShow* CBmpShow::getInstance()
{
	if(m_sInstance==NULL)
		m_sInstance = new CBmpShow;

	return m_sInstance;

}


void CBmpShow::releaseInstance()
{
	if(m_sInstance)
		delete m_sInstance;

	m_sInstance = NULL;
}


void CBmpShow::Make(CDC* pDC,BYTE* pdata,int ilen,int iwidth,int iheight)
{
	BITMAPFILEHEADER filehead;
	filehead.bfType=19778;
	filehead.bfReserved1=0;
	filehead.bfReserved2=0;
	filehead.bfOffBits=54;
	filehead.bfSize=iwidth*iheight*3+54;
	
	BITMAPINFO bmpinfo;
	bmpinfo.bmiHeader.biSize = 40;
	bmpinfo.bmiHeader.biWidth=iwidth;
	bmpinfo.bmiHeader.biHeight=iheight;
	bmpinfo.bmiHeader.biPlanes=1;
	bmpinfo.bmiHeader.biBitCount=8*3;
	bmpinfo.bmiHeader.biCompression=0;
	bmpinfo.bmiHeader.biSizeImage=iwidth*iheight*3;			
	bmpinfo.bmiHeader.biXPelsPerMeter=3780;
	bmpinfo.bmiHeader.biYPelsPerMeter=3780;
	bmpinfo.bmiHeader.biClrImportant=0;
	bmpinfo.bmiHeader.biClrUsed=0;
		
	CTime t = CTime::GetCurrentTime();
	CString strTime;
	strTime.Format("%d_%d_%d",t.GetHour(),t.GetMinute(),t.GetSecond());
	
	CString strFile = "c:\\testvideo.bmp";
	
	CFile newfile;
	newfile.Open(strFile,CFile::modeCreate|CFile::modeWrite);
	newfile.Seek(0,CFile::begin);
	newfile.Write(&filehead,sizeof(BITMAPFILEHEADER));
	newfile.Seek(sizeof(BITMAPFILEHEADER),CFile::begin);
	newfile.Write(&bmpinfo,sizeof(BITMAPINFO));
	newfile.Seek(sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFO)-sizeof(RGBQUAD),CFile::begin);
	newfile.Write(pdata,bmpinfo.bmiHeader.biSizeImage);
	
	newfile.Flush();
	newfile.Close();	


	if(pDC)
	{
		HDC hDesDC = pDC->m_hDC;
		HDC hSrcDC = CreateCompatibleDC(hDesDC);
		HBITMAP hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),
			strFile,
			IMAGE_BITMAP,
			0,
			0,
			LR_LOADFROMFILE|LR_CREATEDIBSECTION);
		//	HBITMAP hBitmap=LoadBitmap(AfxGetInstanceHandle(),dlg.GetPathName());
		BITMAP bm;
		GetObject(hBitmap, sizeof(BITMAP) ,&bm);
		SelectObject(hSrcDC, hBitmap);
		CWnd* pWnd = pDC->GetWindow();
		RECT rect;
		pWnd->GetClientRect(&rect);
		::SetStretchBltMode(hDesDC,COLORONCOLOR);
		::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
		
		DeleteDC(hSrcDC);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -