📄 transjpegview.cpp
字号:
// TransJpegView.cpp : implementation file
//
#include "stdafx.h"
#include "TransClient.h"
#include "TransJpegView.h"
#include "TransClientDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTransJpegView
IMPLEMENT_DYNCREATE(CTransJpegView, CScrollView)
CTransJpegView::CTransJpegView()
{
m_bmInfo.bmiHeader.biBitCount=24;
m_bmInfo.bmiHeader.biClrImportant=0;
m_bmInfo.bmiHeader.biClrUsed=0;
m_bmInfo.bmiHeader.biCompression=BI_RGB;
m_bmInfo.bmiHeader.biHeight=0;
m_bmInfo.bmiHeader.biPlanes=1;
m_bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
m_bmInfo.bmiHeader.biSizeImage=0;
m_bmInfo.bmiHeader.biWidth=0;
m_bmInfo.bmiHeader.biXPelsPerMeter=1;
m_bmInfo.bmiHeader.biYPelsPerMeter=1;
}
CTransJpegView::~CTransJpegView()
{
}
BEGIN_MESSAGE_MAP(CTransJpegView, CScrollView)
//{{AFX_MSG_MAP(CTransJpegView)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTransJpegView drawing
void CTransJpegView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
SetScrollSizes(MM_TEXT,CSize(0,0));
}
void CTransJpegView::OnDraw(CDC* pDC)
{
DrawImg();
}
/////////////////////////////////////////////////////////////////////////////
// CTransJpegView diagnostics
#ifdef _DEBUG
void CTransJpegView::AssertValid() const
{
CScrollView::AssertValid();
}
void CTransJpegView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTransJpegView message handlers
void CTransJpegView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTransClientDoc* pDoc=(CTransClientDoc*)GetDocument();
SetScrollSizes(MM_TEXT,CSize(pDoc->m_ImgWidth,pDoc->m_ImgHeight));
Invalidate(TRUE);
}
void CTransJpegView::DrawImg()
{
CTransClientDoc* pDoc=(CTransClientDoc*)GetDocument();
if (pDoc->m_pDib==NULL || pDoc->m_ImgWidth<=0 || pDoc->m_ImgHeight<=0)
return;
m_bmInfo.bmiHeader.biWidth=pDoc->m_ImgWidth;
m_bmInfo.bmiHeader.biHeight=pDoc->m_ImgHeight;
CDC* pDC=GetDC();
::SetDIBitsToDevice(pDC->GetSafeHdc(),
0,
0,
m_bmInfo.bmiHeader.biWidth,
m_bmInfo.bmiHeader.biHeight,
0,
0,
0,
m_bmInfo.bmiHeader.biHeight,
pDoc->m_pDib,
&m_bmInfo,
DIB_RGB_COLORS);
if (pDoc->m_Frequency>0 && pDoc->m_Bps>0){
pDC->SetTextColor(RGB(0,255,0));
pDC->SetBkColor(RGB(0,0,0));
char str[15];
DWORD FrequencyTmp=(pDoc->m_Frequency[0]+pDoc->m_Frequency[1]+pDoc->m_Frequency[2])/3;
sprintf(str,"fps %.2f",(FrequencyTmp)>0?(float)1000/(FrequencyTmp):0);
::TextOut(pDC->m_hDC,10,10,str,strlen(str));
DWORD BpsTmp=(pDoc->m_Bps[0]+pDoc->m_Bps[1]+pDoc->m_Bps[2])/3;
sprintf(str,"bps %.2fK",(float)BpsTmp/1024);
::TextOut(pDC->m_hDC,10,30,str,strlen(str));
}
ReleaseDC(pDC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -