ubuntu下安装zlib
sodu apt-get install zlib1g-dev
编译的时候需要加上 -lz
.cpp
压缩程序
#include
#include
#include
#include
#define MaxBufferSize 1024*10
int main()
{
int i;
FILE* File_src;
FILE* File_tmp;
FILE* File_dest;
unsigned long len_src;
unsigned long len_tmp;
unsigned long len_dest;
unsigned char *buffer_src = new unsigned char[MaxBufferSize];
unsigned char *buffer_tmp = new unsigned char[MaxBufferSize];
unsigned char *buffer_dest = new unsigned char[MaxBufferSize];
File_src=fopen("src.jpg","r");
len_src =fread(buffer_src,sizeof(char),MaxBufferSize-1,File_src);
compress(buffer_tmp,&len_tmp,buffer_src,len_src);
File_tmp =fopen("tmp.jpg","w");
fwrite(buffer_tmp,sizeof(char),len_tmp,File_tmp);
uncompress(buffer_dest,&len_dest,buffer_tmp,len_tmp);
File_tmp=fopen("tmp.jpg","r");
File_dest=fopen("dest.jpg","w");
fwrite(buffer_dest,sizeof(char),len_dest,File_dest);
printf("OK\n");
}
阅读(2056) | 评论(0) | 转发(0) |