C를 이용한 RLE알고리즘
- 최초 등록일
- 2009.02.03
- 최종 저작일
- 2008.10
- 8페이지/ 한컴오피스
- 가격 1,500원
소개글
RLE압축알고리즘을 C로 구현
목차
1. RLE(run-length encoding)를 이용한 문자 압축 및 해제
2. RLE(run-length-encoding)방법을 이용한 그림파일 압축 및 해제
본문내용
1. RLE(run-length encoding)를 이용한 문자 압축 및 해제
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
long file_length(char filename[]); //파일의 길이 구하는 함수
int RLECompression(FILE *src, char *srcname); //RLE방법을 이용한 압축
int RLEDecompression(FILE *src); //RLE방법을 이용한 압축해제
/* main
o_filename : 압축할 파일이름, c_filename : 압축된 파일이름
압축할 파일을 RLECompression 함수를 이용하여 압축하여 text.rle로 압축
text.rle파일을 RLEDecompression함수를 이용하여 압축풀기
src, decomp_src : 압축을 하고, 풀기위한 파일 포인터
o_filesize, c_filesize : 소스파일과, 압축파일의 크기
*/
int main()
{
FILE *src, *decomp_src;
long o_filesize, c_filesize;
char o_filename[] = string.txt;
char c_filename[] = text.rle;
o_filesize = file_length(o_filename);
if((src=fopen(o_filename, rb))==NULL){
printf( 파일을 열 수 없습니다.n);
return 0;
}
RLECompression(src, o_filename);
c_filesize = file_length(c_filename);
if((decomp_src=fopen(c_filename, rb))==NULL){
printf( 파일을 열 수 없습니다.n);
return 0;
}
RLEDecompression(decomp_src);
fclose(src);
return 0;
참고 자료
없음