亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rle.c

?? 新的RLE壓縮算法
?? C
字號:
/***********************************************************************************************************
	RLE.c

本演示程序提供了游程長度編碼法的壓縮和解壓縮函數,并實現了對圖象
文件的壓縮和解壓縮
**********************************************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_LEN          (0x7f)       /* maximum length for runs or sequences    */
#define MAX_RUN_HEADER  (0xff)       /* bit 7 == 1 : run follows                */
                                  /* bit 6 - 0  : length of run              */
#define MAX_SEQ_HEADER (0x7f)         /* bit 7 == 0 : unencode sequence follows  */
                                  /* bit 6 - 0  : length of sequence         */
#define RUN (0x80)                    /* bit 7 == 1 : run follows                */
#define SEQ (0x00)                    /* bit 7 == 0 : unencoded sequence follows */

/* 函數原型 */
int RLE_Compression(char * infile_name, char * outfile_name);
int RLE_Decompression(char * infile_name, char * outfile_name);

/* 主程序 */
void main(int argc, char *argv[])
{
	printf("RLE compression and decompression utility\n");

	if (4 != argc) 
	{
		printf("\nUsage : rle -c|d sourcefilename targetfilename\n");
		exit(0);
	}

	if (! strcmp(argv[1], "-c"))
	{
		printf("\nCompress...");
		RLE_Compression(argv[2], argv[3]);
	}
	else if (! strcmp(argv[1], "-d"))
	{
		printf("\nDecompress...");
		RLE_Decompression(argv[2], argv[3]);
	}
	else
		printf("\nUnknow command.\n");
}

/**************************************************************************
 RLE_Compression ()

 本函數用RLE算法對文件進行壓縮
 **************************************************************************/
int RLE_Compression(char * infile_name, char * outfile_name)
{
    register int cur_char;                /* a character                    */
    register unsigned int i;              /* generic index variable         */
    register unsigned short run_len = 0;  /* length of character run so far */
    int run_char;                         /* which char run is of           */
    unsigned int j;                       /* another index variable         */
    unsigned short seq_len=0;             /* length of non-run sequence     */

    char scratch_space[256];              /* string scratch space           */
    char seq[MAX_LEN];                    /* buffer for uncompressible data */

    FILE *infile;                           /* file ptr to input file (uncompressed)    */
    FILE *outfile;                          /* file ptr to output file (compressed)     */


    if ((infile=fopen(infile_name, "rb")) == NULL)
    {
        strcpy(scratch_space, "Uable to open ");
        strcat(scratch_space, infile_name);
        puts(scratch_space);
        return 1;
    }

    if ((outfile=fopen(outfile_name, "wb")) == NULL)
    {
        strcpy(scratch_space, "Uable to open ");
        strcat(scratch_space, outfile_name);
        puts(scratch_space);
        return 1;
    }

    while (!feof(infile))
    {
        cur_char = fgetc(infile);

        if (feof(infile))
            continue;

        if (seq_len ==0)                /* haven't got a sequence yet   */
        {
            if (run_len == 0)           /* start a new run              */
            {
                run_char = cur_char;
                ++run_len;
                continue;
            }

            if (run_char == cur_char)   /* got another char in the run  */
                if (++run_len == MAX_LEN)
                {
                    fputc((int)MAX_RUN_HEADER, outfile);
                    fputc((int) run_char, outfile);
                    run_len = 0;
                    continue;
                }

                                   /* got a different character     */
                                   /* than the run we were building */
            if (run_len > 2)       /* so write out the run and      */
                                   /* start a new one of the new    */
                                   /* character.                    */
            {
                fputc((int)(RUN | run_len), outfile);
                fputc((int)run_char, outfile);
                run_len = 1;
                run_char   = cur_char;
                continue;
            }

            /* run was only one or two chars, make a seq out of it instead       */

            for (j = 0; j < run_len; j++);    /* copy 1 or 2 char run to seq[]   */
            {
                seq[seq_len] = run_char;
                ++seq_len;
                if (seq_len == MAX_LEN)       /* if seq[] is full, write to disk */
                {
                    fputc((int)MAX_SEQ_HEADER, outfile);
                    for (i = 0; i < seq_len; i++)
                        fputc((int)seq[i], outfile);
                    seq_len = 0;
                }
            }

            run_len = 0;
            seq[seq_len++] = cur_char;
            if (seq_len == MAX_LEN)        /* if seq[] is full, write to disk */
            {
                fputc((int)MAX_SEQ_HEADER, outfile);
                for (i = 0; i < seq_len; i++)
                    fputc((int)seq[i], outfile);
                seq_len = 0;
            }
        }
        else    /* a sequence exists */
        {
            if (run_len != 0)           /* if a run exists */
            {
                if (cur_char == run_char )  /* add to run!  Yay.  */
                {
                    ++run_len;
                    if (run_len == MAX_LEN)  /* if run is full */
                    {
                        /* write sequence that precedes run */

                        fputc((int)(SEQ | seq_len), outfile);

                        for (i = 0; i < seq_len; i++)
                            fputc((int)seq[i], outfile);

                        /* write run                        */

                        fputc((int)(RUN | run_len), outfile);
                        fputc((int)run_char, outfile);

                        /* and start out fresh              */
                        seq_len = run_len = 0;
                    }  /* end write full run with existing sequence */

                    continue;
                }  /* end add to run for sequence exists */

                /* we couldn't add to the run, and a preceding sequence */
                /* exists, so write the sequence and the run, and       */
                /* try starting a new run with the current character.   */
                /* write sequence that precedes run */

                fputc((int)(SEQ | seq_len), outfile);

                for (i = 0; i < seq_len; i++)
                    fputc((int)seq[i], outfile);

                /* write run                        */

                fputc((int)(RUN | run_len), outfile);
                fputc((int)run_char, outfile);

                /* and start a new run w/ cur_char  */

                seq_len = 0;
                run_len = 1;
                run_char = cur_char;
                continue;

            }    /* end can't add to existing run, and preceding seq exists */

            /* no run exists, but a sequences does.  Try to create a run    */
            /* by looking at cur_char and the last char of the sequence.    */
            /* if that fails, add the char to the sequence.                 */
            /* if the sequence is full, write it to disk.  (Slightly non    */
            /* optimal; we could wait one more char.  A small thing to fix  */
            /* if someone gets the urge...                                  */

            if (seq[seq_len - 1] == cur_char)       /* if we can make a run */
            {
                run_char = cur_char;
                run_len = 2;
                --seq_len;
                continue;
            }

            /* couldn't make a run, add char to seq.  Maybe next time       */
            /* around...                                                    */

            seq[seq_len++] = cur_char;

            if (seq_len == MAX_LEN) /* if the sequence is full, write out   */
            {
                fputc((int)MAX_SEQ_HEADER, outfile);

                for (i = 0; i < MAX_LEN; i++)
                    fputc((int)seq[i], outfile);
                seq_len = 0;
            }
        }  /* end branch on sequence exists */
    } /* done with whole file */

    /* there may be stuff left that hasn't been written yet; if so, write it */

    if (seq_len != 0)  /* write sequence that precedes run */
    {
        fputc((int)(SEQ | seq_len), outfile);

        for (i = 0; i < seq_len; i++)
            fputc((int)seq[i], outfile);
    }

    if (run_len != 0)  /* write run */
    {
        fputc((int)(RUN | run_len), outfile);
        fputc((int)run_char, outfile);
    }

    fclose(infile);
    fclose (outfile);

    return 0;

}  /* end RLE_Compression() */


/**************************************************************************
 RLE_Decompression ()

 本函數用RLE算法對文件進行解壓縮
 **************************************************************************/
int RLE_Decompression(char * infile_name, char * outfile_name)
{
    register int byte;
    register unsigned short i;
    register unsigned short length;
    int packet_hdr;
    char scratch_space[134];

    FILE *infile, *outfile;

    if ((infile=fopen(infile_name, "rb")) == NULL)

    {

        strcpy(scratch_space, "Unable to open ");

        strcat(scratch_space, infile_name);

        puts(scratch_space);

        return 1;

    }

    if ((outfile=fopen(outfile_name, "wb")) == NULL)

    {
        strcpy(scratch_space, "Unable to open ");
        strcat(scratch_space, outfile_name);
        puts(scratch_space);
        return 1;
    }

    while (!feof(infile))
    {
        packet_hdr = fgetc(infile);

        if (feof(infile))
            continue;

        length = MAX_LEN & packet_hdr;

        if (packet_hdr & RUN)  /* if it's a run... */
        {
            byte = fgetc(infile);

            for (i = 0; i < length; i++)
                if (fputc(byte, outfile)== EOF)
                {
                    strcpy(scratch_space, "Error writing to ");
                    strcat(scratch_space, outfile_name);
                    puts(scratch_space);
                    fclose(infile);
                    fclose(outfile);
                    return 1;
                }
        }
        else /* it's a sequence */
            for (i = 0; i < length; i++)
                if (fputc(fgetc(infile), outfile)==EOF)
                {
                    strcpy(scratch_space, "Error writing to ");
                    strcat(scratch_space, outfile_name);
                    puts(scratch_space);
                    fclose(infile);
                    fclose(outfile);
                    return 1;
                }
    }

    fclose(infile);
    fclose(outfile);
    return 0;
}  /* end RLE_Uncompression() */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久久久av影院| 精品奇米国产一区二区三区| 亚洲天堂精品视频| 一区视频在线播放| 91精品福利在线一区二区三区 | 麻豆视频观看网址久久| 香蕉加勒比综合久久| 亚洲一区自拍偷拍| 亚洲第一二三四区| 亚洲777理论| 日韩精品中文字幕一区二区三区| 一区二区成人在线视频| 最新久久zyz资源站| 美女脱光内衣内裤视频久久网站 | 成人精品一区二区三区中文字幕| 国产精品亚洲а∨天堂免在线| 国产美女在线精品| 国产精品99久久久| 在线这里只有精品| 欧美精品一区男女天堂| 亚洲免费观看高清| 国产乱人伦精品一区二区在线观看 | 色综合色狠狠天天综合色| 欧美日韩一区二区三区免费看| 日韩视频永久免费| 亚洲成人综合网站| 久久影院视频免费| 午夜av一区二区三区| 久久爱另类一区二区小说| 97超碰欧美中文字幕| 日韩一区二区中文字幕| 亚洲亚洲人成综合网络| 日本一区二区三区久久久久久久久不| 欧美日韩一卡二卡三卡| 日本一区二区三区四区| 欧美日韩你懂的| 欧美一级二级三级乱码| 日韩精品一区二区三区在线| 欧美一区午夜精品| 久久色在线视频| 亚洲精品成人少妇| 亚洲在线观看免费视频| 丝袜美腿高跟呻吟高潮一区| 欧美—级在线免费片| 日韩精品一区二区三区视频在线观看| 欧美丰满高潮xxxx喷水动漫| 精品污污网站免费看| 精品91自产拍在线观看一区| 欧美激情一区二区三区四区| 日本一区二区视频在线| 亚洲成年人网站在线观看| 一区二区三区精品在线观看| 国产日韩欧美精品一区| 伊人婷婷欧美激情| 国产又粗又猛又爽又黄91精品| 成人av免费网站| 久久麻豆一区二区| 三级欧美韩日大片在线看| 国产精品系列在线播放| 国产在线观看免费一区| 97久久精品人人做人人爽| 日韩一区二区三区四区| 一区二区三区日韩欧美| 亚洲成人免费观看| 成人网男人的天堂| 欧美性大战xxxxx久久久| 日本一区二区三区在线不卡| 欧美三级电影一区| 久久青草欧美一区二区三区| 亚洲成人自拍网| 色婷婷精品久久二区二区蜜臀av| 欧美日韩aaaaa| 亚洲一区二区三区小说| 成人动漫一区二区三区| 中文字幕亚洲综合久久菠萝蜜| 国产成人小视频| 色94色欧美sute亚洲线路一久| 日韩免费性生活视频播放| 日本一区二区三区四区| 色天天综合色天天久久| 亚洲综合在线视频| 欧美一区午夜视频在线观看| 精品夜夜嗨av一区二区三区| 久久精品一二三| 午夜精品一区二区三区三上悠亚 | 中文字幕av一区二区三区| 北条麻妃一区二区三区| 国产精品美女久久久久久2018| 亚洲韩国精品一区| 99久久精品免费看| 性感美女极品91精品| 91精品国产aⅴ一区二区| 精品伊人久久久久7777人| 国产精品久久看| 日韩欧美国产一区二区在线播放 | 亚洲精选在线视频| 精品国产乱码久久久久久图片 | 国产成人精品免费一区二区| 亚洲国产欧美另类丝袜| 国产日韩高清在线| 欧美伦理电影网| 欧美在线视频你懂得| 国产成人aaa| 最近中文字幕一区二区三区| 乱一区二区av| 国产精品一区一区三区| 欧美亚洲动漫精品| 久久综合九色综合欧美亚洲| 国产一区二区三区| 国产精品毛片久久久久久久| 欧美性大战久久| 国产农村妇女精品| 国产一区二区毛片| 国产欧美一区二区精品忘忧草| 天天综合日日夜夜精品| 色婷婷综合久久久久中文| 国产农村妇女毛片精品久久麻豆| 奇米在线7777在线精品| 欧美三级日本三级少妇99| 亚洲激情自拍视频| 91国产精品成人| 亚洲国产精品黑人久久久| 亚洲人成电影网站色mp4| 国产一区二区在线视频| 一区二区三区在线免费视频| 欧美群妇大交群中文字幕| 麻豆精品国产传媒mv男同 | 欧美日韩在线三区| 亚洲国产成人av好男人在线观看| 欧美性极品少妇| 国产精品123区| 亚洲午夜免费电影| 国产精品三级在线观看| 日韩视频一区在线观看| 欧美亚洲高清一区二区三区不卡| 国产精品白丝jk黑袜喷水| 午夜精品久久久久影视| 久久精品欧美一区二区三区不卡| 99久久夜色精品国产网站| 亚洲精品写真福利| 日本一区二区三区免费乱视频 | 欧美电影在哪看比较好| 亚洲综合在线观看视频| www.一区二区| 成人精品视频一区二区三区尤物| 日本成人中文字幕在线视频| 亚洲综合一区二区| 亚洲国产一区二区视频| 日韩经典一区二区| 亚洲大片精品永久免费| 欧美成人精品二区三区99精品| 欧美欧美欧美欧美| 亚洲成人在线网站| 亚洲一区二区影院| 一区二区三区日韩欧美| 日韩欧美综合在线| 日韩毛片一二三区| 一区二区三区日韩在线观看| 日韩女同互慰一区二区| 成人免费毛片嘿嘿连载视频| 亚洲欧美日韩一区| 中文一区一区三区高中清不卡| 亚洲图片激情小说| 欧美一区二区三区性视频| 欧美日韩国产片| 亚洲国产精品人人做人人爽| 国产欧美日韩中文久久| 欧美日韩国产免费| 欧美一二三区在线观看| 国产日韩影视精品| 亚洲国产精品精华液网站 | 欧美三级日韩在线| 不卡一区二区在线| 99v久久综合狠狠综合久久| www.日本不卡| 亚洲一二三四在线| 国产一区二区久久| 91在线小视频| 欧美一级片在线观看| 日韩欧美123| 久久狠狠亚洲综合| 狠狠v欧美v日韩v亚洲ⅴ| 午夜精品免费在线| 国产精品一级片| 欧美日韩视频在线第一区| 色视频欧美一区二区三区| 日韩免费性生活视频播放| www.在线成人| 欧美日韩国产免费一区二区| 日韩一级完整毛片| av一区二区不卡| 亚洲色图视频网站| 色欧美片视频在线观看| 国产精品亲子乱子伦xxxx裸| 日韩午夜激情视频| 精品一区二区三区免费观看 | 国产日韩欧美一区二区三区乱码| 欧美在线免费观看视频| 91精品免费在线观看| 亚洲精品国产视频|