?? showstreamdlg.cpp
字號:
// ShowStreamDlg.cpp : implementation file
//
#include "stdafx.h"
#include "multicard.h"
#include "ShowStreamDlg.h"
#include "ChildFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*typedef struct tagSTREAMNOTIFYPARAME
{
int iDlgCount;
CShowStreamDlg * pDlgArray;
} STREAMNOTIFYPARAME;*/
#define WIDTH (320)//(160)
#define HEIGHT (240)//(120)修改數據流回調顯示的大小 02 10 16 23:29
/////////////////////////////////////////////////////////////////////////////
// CShowStreamDlg dialog
CShowStreamDlg::CShowStreamDlg(CWnd* pParent /*=NULL*/)
: CDialog(CShowStreamDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CShowStreamDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bIs4WayCard = false; //是否是四路實時卡
m_iShowWay=0; //如果是四路實時卡,顯示第幾路圖像
Prsed=FALSE;
counts=0;
//pLastFrame=new BYTE[320*240*3];
}
void CShowStreamDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShowStreamDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShowStreamDlg, CDialog)
//{{AFX_MSG_MAP(CShowStreamDlg)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowStreamDlg message handlers
BOOL CShowStreamDlg::OnInitDialog()
{
//將客戶區窗口的大小改為 160 x 120
CDialog::OnInitDialog();
RECT rcFrame, rcClient;
int w, h;
int width, height;
GetWindowRect(&rcFrame);
GetClientRect(&rcClient);
w = (rcFrame.right-rcFrame.left) - (rcClient.right-rcClient.left);
h = (rcFrame.bottom-rcFrame.top) - (rcClient.bottom-rcClient.top);
width =WIDTH + w;//rcClient.right-rcClient.left+
height = HEIGHT + h;///客戶區的邊框風格與圖像框相同rcClient.bottom-rcClient.top+
SetWindowPos(NULL, -1, -1, width, height, SWP_NOZORDER|SWP_NOMOVE);//SWP_NOSIZE|SWP_NOZORDER| SWP_NOACTIVATE|SWP_SHOWWINDOW
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CShowStreamDlg::OnOK()
{
}
void CShowStreamDlg::OnCancel()
{
}
void CShowStreamDlg::ShowStream(const BITMAPINFO * pInfo, const BYTE * pBits)
{
if(!pInfo || !pBits)
return;
HDC hdc = ::GetDC(m_hWnd);
int w = pInfo->bmiHeader.biWidth;
int h = pInfo->bmiHeader.biHeight;
RECT rcClient;
GetClientRect(&rcClient);///獲得當前的客戶區大小,以適應窗口的拖動
int ww = (rcClient.right-rcClient.left);//2002.11.14 12:21 ^_^
int hh = ww*3/4 ;//(rc.bottom-rc.top)
/*float rt=0;float rt1,rt2;
rt1=ww/320;rt2=hh/240;
rt=(rt1>=rt2)?rt2:rt1;
ww=(int)rt*320;
hh=(int)rt*240;*/
SetStretchBltMode(hdc, COLORONCOLOR);
//不是四路實時卡
if(!m_bIs4WayCard)
{
StretchDIBits(hdc,
0, 0,ww,hh, //WIDTH, HEIGHT,
0, 0, w, h,
pBits, pInfo, DIB_RGB_COLORS, SRCCOPY);
}
//是四路實時卡
else
{
POINT ptS[4] = { {0,h/2}, {w/2,h/2}, {0,0}, {w/2,0} };
StretchDIBits(hdc,
0, 0, WIDTH, HEIGHT,
ptS[m_iShowWay].x, ptS[m_iShowWay].y, w/2, h/2,
pBits, pInfo, DIB_RGB_COLORS, SRCCOPY);
}
::ReleaseDC(m_hWnd, hdc);
}
//設置是否是四路實時卡,
//如果是四路實時卡,設置顯示第幾路圖像
void CShowStreamDlg::SetShowWay(int iCardID, bool bIs4WayCard, int iWay/*=0*/)
{
m_bIs4WayCard = bIs4WayCard;
if(m_bIs4WayCard && iWay>=0 && iWay<=3)
m_iShowWay = iWay;
else
m_iShowWay = 0;
char szCaption[100];
if(m_bIs4WayCard)
sprintf(szCaption, "%d號卡 (路數%d)", iCardID, m_iShowWay);
else
sprintf(szCaption, "%d號卡: 數據流回調顯示", iCardID);
SetWindowText(szCaption);
}
void CShowStreamDlg::DisplayGrayImage(const BITMAPINFO *pInfo, const BYTE *pBits)
{
if(!pInfo || !pBits)
return ;
HDC hdc = ::GetDC(m_hWnd);
int w = pInfo->bmiHeader.biWidth;
int h = pInfo->bmiHeader.biHeight;
BYTE *GrayImage=(BYTE *)(new BYTE[w*h*3]);///必須預先分配內存大小
SetStretchBltMode(hdc, COLORONCOLOR);
for (int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
GrayImage[i*3*w+j*3+0]=(const BYTE)(pBits[i*3*w+j*3+0]*0.299+pBits[i*3*w+j*3+1]*0.587+pBits[i*3*w+j*3+2]*0.114);
GrayImage[i*3*w+j*3+1]=GrayImage[i*3*w+j*3+0];
GrayImage[i*3*w+j*3+2]=GrayImage[i*3*w+j*3+0];
}
StretchDIBits(hdc,
0, 0, w, h,///目的區域大小(顯示面積)
0, 0, w, h, ///源區域的大小(要顯示的原圖像中的那一部分)
GrayImage/*plastFrame*/, pInfo, DIB_RGB_COLORS, SRCCOPY);
delete [] GrayImage;///釋放內存
::ReleaseDC(m_hWnd, hdc);
}
void CShowStreamDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
RECT rcFrame, rcClient;
GetClientRect(&rcClient);///獲得當前的客戶區大小,以適應窗口的拖動
int ww = (rcClient.right-rcClient.left);//2002.11.14 12:21 ^_^
int hh = ww*3/4 ;//(rc.bottom-rc.top)
int w1, h1;
int width, height;
GetWindowRect(&rcFrame);
w1 = (rcFrame.right-rcFrame.left) - (rcClient.right-rcClient.left);
h1 = (rcFrame.bottom-rcFrame.top) - (rcClient.bottom-rcClient.top);
width =ww + w1;//rcClient.right-rcClient.left+
height = hh + h1;///客戶區的邊框風格與圖像框相同rcClient.bottom-rcClient.top+
SetWindowPos(NULL, -1, -1, width, height, SWP_NOZORDER|SWP_NOMOVE);
//MessageBox("changed");
// TODO: Add your message handler code here
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -