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

📄 facectrl.c

📁 使用tc2的adaptive huffman编码
💻 C
📖 第 1 页 / 共 2 页
字号:
		   case 3:drawselection(250,232,10,"   Input Dictionary ");break;
		   case 4:drawselection(250,277,10,"  Output Dictionary ");break;
		   case 5:drawselection(250,322,10,"       Go Now!      ");break;
	       }
	       break;
	case 2:
	       break;
	case 3:
	       switch(iButton)
	       {
		   case 1:drawselection(250,142,10,"   Input Dictionary ");break;
		   case 2:drawselection(250,187,10,"  Output Dictionary ");break;
		   case 5:drawselection(250,322,10,"       Compare      ");break;
	       }
	       break;
	case 4:
	       switch(iButton)
	       {
		   case 1:drawselection(250,142,10,"       To Users     ");break;
		   case 2:drawselection(250,187,10,"        About       ");break;
		   case 3:drawselection(250,232,10,"     The Author     ");break;
	       }
	       break;
	case 5:
	       switch(iButton)
	       {
		   case 5:drawselection(250,322,10,"       Confirm      ");break;
	       }
	       break;
    }
}



/*show input viewport*/
void InputPort(status1 *s1)
{
    char str[128];


    restorecrtmode();
    window(20,11,60,16);
    textbackground(0);
    textcolor(1);
    gotoxy(20,1);
    cprintf("Input the path:\n");
    textcolor(15);
    gotoxy(1,2);


    cgets(str);
    strcpy(s1->pchinput,str+2);

    setgraphmode(getgraphmode());
    InitBG(s1);

}

/*to write the output dictionary*/
void Outport(status1* s1)
{

    int i;
    char str[128];


    restorecrtmode();
    window(20,11,60,16);
    textbackground(0);
    textcolor(1);
    gotoxy(20,1);
    cprintf("Input the path:\n");
    textcolor(15);
    gotoxy(1,2);


    cgets(str);
    strcpy(s1->pchoutput,str+2);

    setgraphmode(getgraphmode());
    InitBG(s1);
}


/*file initialize*/
void InitFile(FILE *fp1,FILE *fp2,status1 *s1)
{
    unsigned long lSameByte=1;
    double dCom=1;
    fp1=fopen(s1->pchinput,"rb");
    fp2=fopen(s1->pchoutput,"wb");
    if(fp1==0||fp2==0)
    {
	printf("Open error!");
	exit(0);
    }
    s1->lF1Size=FileSize(fp1);
    s1->lF2Size=FileSize(fp2);
    dCom=(double)s1->lF1Size/s1->lF2Size*100;
    s1->lRatioSize=(unsigned long)(dCom);
    lSameByte=SameByte(fp1,fp2);
    dCom=((double)lSameByte)/s1->lF2Size*100;
    s1->lRatioByte=(unsigned long)(dCom);
}


void Ctrl()
{


    char* buffer;
    static status1 s1;
	unsigned long lSameByte=1;
    double dCom=1;
    int iMode;
    /*x1,y1,ect is the memory stored the mouse position,x0..is the original position*/
    int i,*x,*y,*button,x0=320,x1=320,y0=240,y1=240,button1=-1,button0=-1;

    /*button initialization*/
    int ButtonOrder=1,SelOrder;
    int ButtonChanged=0,ButtonClick=0,SelChanged=0,SelClick=0;

    static FILE *fp1,*fp2;

    /*status initialization*/
    x=&x1;y=&y1;button=&button1;
    s1.iMode=1;
    s1.iSubmode=1;
    strcpy(s1.pchinput,"e:\\p\\dcce\\sample.txt");
    strcpy(s1.pchoutput,"e:\\p\\dcce\\sample.huf");

    /*InitFile(*fp1,*fp2,&s1);*/

    /*fp1=fopen(s1.pchinput,"rb");*/
 /*    fp2=fopen(s1.pchoutput,"wb");*/
   /* if(fp1==0||fp2==0)*/
 /*    {*/
 /*	printf("Open error!");*/
 /*	exit(0);*/
 /*    }*/
    s1.lF1Size=FileSize(fp1);
    s1.lF2Size=FileSize(fp2);

    InitBG(&s1);

    /*Allocate some memory to the Buffer*/
    buffer=(char*)malloc(imagesize(0,0,10,10));


    i=Msinit(1,629,1,480);
    getimage(320,240,320+10,240+10,buffer);
    cursor(*x,*y);
    while(1)
    {

	Msread(x,y,button);
	if(*x!=x0||*y!=y0||*button!=button0)
	{
	    putimage(x0,y0,buffer,0);
	    /*If it's not from non-button/selection zone to button/selection zone*/
	    if(!(!isButton(x0,y0)&&isButton(*x,*y)))
	    {
		getimage(*x,*y,*x+10,*y+10,buffer);
		cursor(*x,*y);
	    }

	    /*Active Button and Selection*/

	    ButtonOrder=isButton(*x,*y);

	    if(ButtonOrder!=0)
	    {
		/*if from other zone to button*/
		if(ButtonChanged==0)
		{
		    DrawOnMove(ButtonOrder);
		    /*If it's from non-button zone to button zone
		      get image after drawed*/
		    if(!isButton(x0,y0)&&isButton(*x,*y))
		    {
			getimage(*x,*y,*x+10,*y+10,buffer);
			cursor(*x,*y);
		    }
		    putimage(*x,*y,buffer,0);
		    getimage(*x,*y,*x+10,*y+10,buffer);
		    cursor(*x,*y);
		}
		if(*button==1)
		{
		    DrawOnClick(ButtonOrder);
		    putimage(*x,*y,buffer,0);
		    getimage(*x,*y,*x+10,*y+10,buffer);

		    cursor(*x,*y);
		    ButtonClick=1;
		    s1.iMode=ButtonOrder;
		    switch(ButtonOrder)
		    {
			case 5:;


		    }
		}
		if(*button==0&&ButtonClick==1)
		{
		    ButtonClick=0;
		    DrawOnMove(ButtonOrder);
		    putimage(*x,*y,buffer,0);
		    getimage(*x,*y,*x+10,*y+10,buffer);
		    cursor(*x,*y);
		}
		if(ButtonChanged==0)
		{
		    ButtonChanged=1;
		}
	    }
	    if(ButtonOrder==0&&ButtonChanged==1)
	    {
		putimage(*x,*y,buffer,0);
		/*return to normal*/
		drawButtonxy(120,132,4,"   Coding  ");
		drawButtonxy(120,177,4,"   Result  ");
		drawButtonxy(120,222,4,"   Differ  ");
		drawButtonxy(120,267,4,"    Help   ");
		drawButtonxy(120,312,4,"    Exit   ");
		    drawFace1(&s1);
		getimage(*x,*y,*x+10,*y+10,buffer);
		ButtonChanged=0;
	    }


	    putimage(*x,*y,buffer,0);
	    if(!(!isSel(x0,y0)&&isSel(*x,*y)))
	    {
		getimage(*x,*y,*x+10,*y+10,buffer);
		cursor(*x,*y);
	    }

	    /*Active Selection*/
	    SelOrder=isSel(*x,*y);
	    if(SelOrder!=0&&iMode!=2)
	    {
		/*if from other zone to selection*/
		if(SelChanged==0)
		{
		    DrawOnSel(s1.iMode,SelOrder);
		    /*If it's not from non-selection zone to selection zone*/
		    if(!isSel(x0,y0)&&isSel(*x,*y))
		    {
			getimage(*x,*y,*x+10,*y+10,buffer);
			cursor(*x,*y);
		    }
		    putimage(*x,*y,buffer,0);
		    getimage(*x,*y,*x+10,*y+10,buffer);
		    cursor(*x,*y);
		}
		if(*button==1)
		{
		    /*the iMode1/2 denotes de/encode in mode1*/
		    if(s1.iMode!=1)
		    {
			s1.iSubmode=SelOrder;
		    }
		    switch(s1.iMode)
		    {
			case 1:
			       switch(SelOrder)
			       {
				    case 1:s1.iSubmode=1;break;
				    case 2:s1.iSubmode=2;break;
				    case 3:InputPort(&s1);
					   if(s1.iSubmode==1)
					   {
					     if((fp1=fopen(s1.pchinput,"rb"))==0)
						printf("Open Error!");
					   }
					   else
					     if((fp1=fopen(s1.pchinput,"rb"))==0)
						printf("Open Error!");
					   break;
				    case 4:Outport(&s1);
					   if(s1.iSubmode==1)
					   {
					     if((fp2=fopen(s1.pchoutput,"wb"))==0)
						printf("Open Error!");
					   }
					   else
					     if((fp2=fopen(s1.pchoutput,"wb"))==0)
						printf("Open Error!");
					   break;
				    case 5:
						if(s1.iSubmode==1)
						Encoder(fp1,fp2,&s1);
						else
							Decoder(fp1,fp2);
						break;
			       }
			       break;
			case 2:
			       break;
			case 3:
			       switch(SelOrder)
			       {
				    case 1:InputPort(&s1);break;
				    case 2:Outport(&s1);break;
				    case 5:Compare(&s1);break;
			       }
			       break;
			case 4:
			       break;
			case 5:switch(SelOrder)
			       {
				    case 5:
					   closegraph();
					   exit(1);
					   break;
			       }
		    }


		}
		if(*button==0&&SelClick==1)
		{
		    ButtonClick=0;
		}
		if(SelChanged==0);
		{
		    SelChanged=1;
		}
	    }

	    /*return to normal*/
	    if(SelOrder==0&&SelChanged==1)
	    {
		putimage(*x,*y,buffer,0);

		drawFace1(&s1);
		showstatus(&s1);
		getimage(*x,*y,*x+10,*y+10,buffer);
		SelChanged=0;
	    }
	}

	x0=*x;y0=*y;button0=*button;
    }
	fclose(fp1);fclose(fp2);

}

⌨️ 快捷键说明

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