📄 acdialog.cpp
字号:
// ACDialog.cpp : implementation file
//
#include "stdafx.h"
#include "entropyCoding.h"
#include "ACDialog.h"
#include "AC_En.h"
#include "AC_De.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CACDialog dialog
CACDialog::CACDialog(CWnd* pParent /*=NULL*/)
: CDialog(CACDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CACDialog)
m_infile = _T("");
m_outfile = _T("");
//}}AFX_DATA_INIT
}
void CACDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CACDialog)
DDX_Text(pDX, IDC_EDIT1, m_infile);
DDX_Text(pDX, IDC_EDIT2, m_outfile);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CACDialog, CDialog)
//{{AFX_MSG_MAP(CACDialog)
ON_BN_CLICKED(IDC_BUTTON_open1, OnBUTTONopen1)
ON_BN_CLICKED(IDC_BUTTON_Open2, OnBUTTONOpen2)
ON_BN_CLICKED(IDC_BUTTON_De, OnBUTTONDe)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CACDialog message handlers
void CACDialog::OnBUTTONopen1()
{
UpdateData(true);
static char szFilter[] = "raw(*.raw)|*.raw|huf(*.huf)|*.huf|acc(*.acc)|*.acc|run(*.run)|*.run|";
CFileDialog FileDlg( TRUE, NULL,NULL,OFN_HIDEREADONLY, szFilter);
if( FileDlg.DoModal() == IDOK )
{
m_szFilePathName1=FileDlg.GetPathName();
}
else
{
m_szFilePathName1 = "F:\\standard_pictures\\MISSUSA_raw\\lena.raw";
}
m_infile=m_szFilePathName1;
m_outfile=m_infile.Left(m_infile.GetLength()-4);
if(m_infile.Right(3)=="raw")
m_outfile=m_outfile+".acc";
else
m_outfile=m_outfile+"_De.raw";
UpdateData(false);
}
void CACDialog::OnBUTTONOpen2()
{
UpdateData(true);
static char szFilter[] = "ALL Files(*.*)|*.*|";
CFileDialog FileDlg( TRUE, NULL,NULL,OFN_HIDEREADONLY, szFilter);
if( FileDlg.DoModal() == IDOK )
{
m_szFilePathName2=FileDlg.GetPathName();
}
else
{
m_szFilePathName2 = "F:\\standard_pictures\\MISSUSA_raw\\lena.raw";
}
m_outfile=m_szFilePathName2;
UpdateData(false);
}
void CACDialog::OnOK()
{
BYTE * pData;
int m_width,m_height;
m_width=256;
m_height=256;
long lFileSize = m_width * m_height;
pData = (BYTE*)new char[lFileSize];
CFile file;
if((file.Open(m_infile,CFile::modeRead|CFile::shareDenyNone))==NULL)
{
AfxMessageBox("Can not open the file");
return ;
}
if(!pData)
return ;
file.ReadHuge(pData,lFileSize);
file.Close();
if((fp_out=fopen(m_outfile,"wb"))==NULL)
AfxMessageBox ("ERROR! Code Value Out of Range. Cannot Compress.\n");
AC_code(pData,m_width,m_height);
CString info;
info.Format("算术编码结束!输出文件:%s\n输入",m_outfile);//second
AfxMessageBox(info);
}
void CACDialog::OnBUTTONDe()
{
BYTE * pData;
int m_width,m_height;
m_width=256;
m_height=256;
long lFileSize = m_width * m_height;
pData = (BYTE*)new char[lFileSize];
fp_in=fopen(m_infile,"rb");
fp_out=fopen(m_outfile,"wb");
pData=AC_decode(m_width,m_height);
CString info;
info.Format("算术解码结束!输出文件:%s",m_outfile);//second
AfxMessageBox(info);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -