📄 reayuvdlg.cpp
字号:
// ReaYUVDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ReaYUV.h"
#include "ReaYUVDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReaYUVDlg dialog
CReaYUVDlg::CReaYUVDlg(CWnd* pParent /*=NULL*/)
: CDialog(CReaYUVDlg::IDD, pParent)
{
m_bDraw = FALSE;
//{{AFX_DATA_INIT(CReaYUVDlg)
// 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 CReaYUVDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReaYUVDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReaYUVDlg, CDialog)
//{{AFX_MSG_MAP(CReaYUVDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReaYUVDlg message handlers
BOOL CReaYUVDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CReaYUVDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CFile file(_T("123.txt"),CFile::modeRead);
char *pBuf;
DWORD dwFileLen;
dwFileLen=file.GetLength();
pBuf=new char[dwFileLen+1];
file.Read(pBuf,dwFileLen);
pBuf[dwFileLen]=0;
CString str1,str2,str3;
CString str4[216]; //测量点的个数+数据文件头16行,即可测量200个点
int t=0;
int dData[3];
int i=0;
int k=0;
for(;i<dwFileLen;i++)
{
str2+=pBuf[i];
if ('\n'==pBuf[i])
{
MessageBox(str2);
int t=str2.GetLength();
str3.Empty();
for(int j=0;j<t;j++)
{
str3+=str2.GetAt(j);
if(','==str2.GetAt(j))
{
int p=0;
char temp[4];
MessageBox(str3);
int m=str3.GetLength();
for(int g=0;g<m;g++)
{
temp[g]=(char)str3.GetAt(g);
}
temp[m-1]='\0';
dData[p] = atoi(temp);
str3.Empty();
p++;
}
myRGB[k].R = dData[0];
myRGB[k].R = dData[1];
myRGB[k].R = dData[2];
k++;
}
// dc.SetPixel(l,k,RGB(dData[0],dData[1],dData[2]));
str2.Empty();
}
}
file.Close();
}
void CReaYUVDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_bDraw =TRUE;
Invalidate();
}
void CReaYUVDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
int k=0;
// TODO: Add your message handler code here
if(m_bDraw)
{
for (int h=0;h<320;h++)
{
for (int w =0; w<240; w++)
{
// dc.SetPixel(w,h,RGB(myRGB[k].R,myRGB[k].G,myRGB[k].B));
// k++;
}
}
}
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -