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

📄 compress.cpp

📁 一个数据结构课程之后自己编写的lzw压缩算法
💻 CPP
字号:
// compress.cpp : implementation file
//

#include "stdafx.h"
#include "lzw.h"
#include "compress.h"
#include "aid.h"


//#include "iostream.h"
//#include "fstream.h"

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

/////////////////////////////////////////////////////////////////////////////
// compress dialog


compress::compress(CWnd* pParent /*=NULL*/)
	: CDialog(compress::IDD, pParent)
{
	//{{AFX_DATA_INIT(compress)
	m_filepath1 = _T("");
	m_filename1 = _T("");
	m_filepath2 = _T("");
	m_filename2 = _T("");
	//}}AFX_DATA_INIT
}


void compress::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(compress)
	DDX_Text(pDX, IDC_EDIT1, m_filepath1);
	DDX_Text(pDX, IDC_EDIT2, m_filename1);
	DDX_Text(pDX, IDC_EDIT3, m_filepath2);
	DDX_Text(pDX, IDC_EDIT4, m_filename2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(compress, CDialog)
	//{{AFX_MSG_MAP(compress)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// compress message handlers

void compress::OnButton1() 
{
		// TODO: Add your control notification handler code here
		char directory[100];
		SHGetSpecialFolderPath(NULL, directory, CSIDL_DESKTOP, 0);
		CFileDialog fd(TRUE, "txt", NULL, OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST, " 文本文档(.txt)|*.txt|所有文件(*.*)|*.*||");
		fd.m_ofn.lpstrInitialDir = directory;
		if (fd.DoModal()==IDOK)
		{
			m_filepath1 = fd.GetPathName();
			m_filename1 = fd.GetFileName();
			UpdateData(FALSE);
		}


}

void compress::OnButton2() 
{
	// TODO: Add your control notification handler code here
	char directory[100];
	SHGetSpecialFolderPath(NULL, directory, CSIDL_DESKTOP, 0);
	CFileDialog fd(FALSE, "pzc", NULL, OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT, " 压缩文档(.pzc)|*.pzc|所有文件(*.*)|*.*||");
	fd.m_ofn.lpstrInitialDir = directory;
	if (fd.DoModal()==IDOK)		
	{
		m_filepath2 = fd.GetPathName();
		m_filename2 = fd.GetFileName();
		UpdateData(FALSE);
	}
}




void compress::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	clear(m_filepath2);
	HASH hash[4098];
	initial(hash);
	char* filecontent="";
	int lenth,len=getfilelen1(m_filepath1);
	filecontent=readfile(m_filepath1,len);
	int* numfile=new int [len];
	cmps (hash,filecontent,numfile,lenth);
	bitnumshort(numfile,lenth,m_filepath2);
	delete[] filecontent;
	delete[] numfile;
	int j=MessageBox("  完成!  ","Finish     ", MB_OK);
	if(j=IDOK) 	CDialog::OnOK();
}



⌨️ 快捷键说明

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