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

📄 mga_view.c

📁 linux下显示各种格式图片
💻 C
📖 第 1 页 / 共 2 页
字号:
	i=tabb[x+xxx*y];	tabb[x+xxx*y]=tabb[xxx-x-1+xxx*y];	tabb[xxx-x-1+xxx*y]=i;}	if (is_matrox==1) draw_image(image_x,image_y); else draw_image_fb(0);	} else {    for (x=0;x<xxx/2;x++) 	for (y=0;y<yyy;y++) {	    i=y_image[x+xxx*y];	    y_image[x+xxx*y]=y_image[xxx-x-1+xxx*y];	    y_image[xxx-x-1+xxx*y]=i;    }    xxx=xxx/2;    yyy=yyy/2;    for (x=0;x<xxx/2;x++) 	for (y=0;y<yyy;y++) {	    i=cr_image[x+xxx*y];	    cr_image[x+xxx*y]=cr_image[xxx-x-1+xxx*y];	    cr_image[xxx-x-1+xxx*y]=i;	    i=cb_image[x+xxx*y];	    cb_image[x+xxx*y]=cb_image[xxx-x-1+xxx*y];	    cb_image[xxx-x-1+xxx*y]=i;    }	write_frame(y_image,cr_image,cb_image);	}}void rew_chk(){	rewind(plik);	if ((kod==3)) {	    toob=3;	    kod=1;	    }	if ((kod==0)) {	    toob=0;	    kod=0;	    }	    }void detect_image(){	YU12=0;	toob=0;	zoom=1;	if (kod==1) kod=detect_png();	rew_chk();	if (kod==1) kod=detect_gfl();	rew_chk();	if (kod==1) kod=detect_tiff();	rew_chk();	if (kod==1) kod=detect_zmg();	if ((YU12==1) && (is_matrox==0)) yuv_rgb(image_x,image_y);	rew_chk();	if (kod==1) kod=detect_gif();	rew_chk();	if (kod==1) kod=detect_epa();	rew_chk();	if (kod==1) kod=detect_raw();	rew_chk();	if (kod==1) kod=detect_psd();	rew_chk();	if (kod==1) kod=detect_jpg();	rew_chk();	if (kod==1) kod=detect_xpm();	rew_chk();	if (kod==1) kod=detect_xwd();	rew_chk();	if (kod==1) kod=detect_pxm();	rew_chk();	if (kod==1) kod=detect_pat();	rew_chk();	if (kod==1) kod=detect_pcx();	rew_chk();	if (kod==1) kod=detect_bmp();	rew_chk();	if (kod==1) kod=detect_hrz();	rew_chk();	if (kod==1) kod=detect_pic();	rew_chk();	if (kod==1) kod=detect_rix();	rew_chk();	if (kod==1) kod=detect_ras();	rew_chk();	if (kod==1) kod=detect_pi2();	rew_chk();	if (kod==1) kod=detect_pi3();	rew_chk();	if (kod==1) kod=detect_pi4();	rew_chk();	if (kod==1) kod=detect_mtv();	rew_chk();	if (kod==1) kod=detect_vst();	rew_chk();	if (kod==1) kod=detect_rgb();	rew_chk();	if (kod==1) kod=detect_ska();	rew_chk();	if (kod==1) kod=detect_tga();	if (kod==3) kod=1;	rew_chk();	if (kod==1) kod=detect_cut();	if (kod==3) kod=1;	rew_chk();	if (kod==1) kod=detect_mag(1);	rew_chk();	if (kod==1) kod=detect_lbm();	rew_chk();	if ((kod==1) && (toob==0) && (multi<3)) {	    fprintf(stderr,"\x1B[1;31m%s\x1B[0;31m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");fprintf(stderr,": ");	    fprintf(stderr,"Unknown file format !\x1B[0;0m\n");	    }	if ((toob==3) && (multi<3)) {	    fprintf(stderr,"\x1B[1;31m%s\x1B[0;31m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");fprintf(stderr,": ");	    fprintf(stderr,"File too big !\x1B[0;0m\n");	    }}int init_x(){#ifdef USE_X    char *displayname=NULL;    int blackp,whitep;    display=XOpenDisplay(displayname);    if (display==NULL) {	return 0;	}    screen_nr=DefaultScreen(display);    tx=DisplayWidth(display,screen_nr);    ty=DisplayHeight(display,screen_nr);    tdepth=DefaultDepth(display,window);    blackp=BlackPixel(display,screen_nr);    whitep=WhitePixel(display,screen_nr);    window=XCreateSimpleWindow(display,DefaultRootWindow(display),0,0,66,66,0,blackp,blackp);    XStoreName(display,window,"Xmgaview (c) HelDoRe");    XSelectInput(display,window,KeyPressMask|ExposureMask|ButtonPressMask);    XMapRaised(display,window);    gc=XCreateGC(display,window,0,NULL);    XSetForeground(display,gc,whitep);    return 1;#else    return 0;#endif}void wait_key(int ile){	set_raw(3) ;	do {	    if (is_matrox==0) ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo);	    kod = kbhit() ;//	    printf("%i\n",kod);	    if ((kod != 32) && (kod != 115) && (kod!=102) && (kod!=127) && (kod!=114) && (kod!=70) && (kod!=103) && (kod!=99) && (kod!=116) && (kod!=91) && (kod!=93) && (kod!=112)) {	    obr+=ile;	    }        if (kod==32) {	clear_bottom();	}	    if ((kod ==99)) {		if (zmgm<=2) {		    if (zmgm==1) zmgm=2; else zmgm=1;		    }		if (zmgm>=3) {		    if (zmgm==3) zmgm=4; else zmgm=3;		    }		kod = 0 ;		}	    if ((kod ==116) && (is_matrox==1)) {		mga_transp();		kod = 0 ;		}	    if ((kod ==103)) {		if (is_matrox==1) mga_grey(); else {		if ((grey==0) && (YU12==0)) rgb_yuv(image_x,image_y);		fb_grey();		}		kod = 0 ;		}	    if ((kod ==102)) {		if (is_matrox==1) mga_fs(); else fb_fs();		kod = 0 ;		}	    if ((kod ==70) && (is_matrox==1)) {		fullscr=4;		mga_fs();		kod = 0 ;		}	    if ((kod ==114) || (kod==112)){		clear_bottom();		obr--;		if (kod==112) {		    if (ori==0) ori=1; else ori=0;		    }		}	    if (kod ==127) {		clear_bottom();		if (obr>1) obr-=2; else kod=0;		}	    if ((kod==115) && (YU12==0)) {		if (is_matrox==0) rgb_yuv(image_x,image_y);		save_zmg(zmgm);		kod = 0 ;		}	    if ((kod==115) && (YU12==1)) {		if (is_matrox==1) yuv_rgb(image_x,image_y);	        save_tga();		kod = 0 ;		}	    if ((kod ==91)) {		flip_image_v();		kod = 0 ;		}	    if ((kod ==93)) {		flip_image_h();		kod = 0 ;		}	    } 	while (kod ==0) ; 	if (kod==27) {	    kod = kbhit() ;	if (kod!=27) {	    kod = kbhit() ;	    kod = kbhit() ;	    }	}	set_raw(0) ;}void wait_x_key(){#ifdef USE_X    int loop_end;    loop_end=0;    while (!loop_end) {    XNextEvent(display,&event);	switch (event.type) {	    case KeyPress:loop_end=1;break;	    case ButtonPress:loop_end=1;break;	    case DestroyNotify:loop_end=1;printf("FUCK!!!!\n");break;	    default:break;	    }    }#endif}void shutdown(){#ifdef USE_X    if (iksy==1) {        XFreeGC(display,gc);        XDestroyWindow(display,window);//	XCloseDisplay(display);    }#endif	close(fb_dev_fd);	close(f);	free(tabr);	free(tab2r);	free(tabg);	free(tab2g);	free(tabb);	free(tab2b);}int main(int argc, char *argv[]){iksy=0;#ifdef USE_X	iksy=init_x();#endif//	if (iksy==1) printf("Sa iksy ;-)\n");	        init_fb();	multi=argc;	is_matrox=1;	trans=0;	f = open("/dev/mga_vid",O_RDWR);	if(f == -1)	{		is_matrox=0;	}	if (iksy==0) {	    clear_bottom();	    fprintf(stderr,"\nmga_vid image viewer v%s\n",VERSION2);	    fprintf(stderr,"\x1B[1;30mCompile time    : %s %s\x1B[0;0m\n",__DATE__,__TIME__);	    fprintf(stderr,"\x1B[0;38mhttp://mgaview.sourceforge.net\x1B[0;0m\n\n");	}	mee=argv[1];	if (argc==1 && iksy==0) {	mee="-h";	}	long_help(argv[0]);	if (iksy==1) is_matrox=0;	if (is_matrox==0) {		fprintf(stderr,"\x1B[1;30mSome functions are disabled in FB mode.\x1B[0;0m\n\n");//	    init_fb();	    mga_vid_base=fb_mem;	    }			zmgm=2;				kod=1;		for (obr=1;obr<argc;obr++) {	if (start_zoom == 1 && obr == 1) obr++;	mee=argv[obr];	    dir=0;	if ((plik = fopen(mee,"r")) ==NULL)	    {	    fprintf(stderr,"\x1B[1;31m%s\x1B[0;31m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");fprintf(stderr,": ");	    fprintf(stderr,"File not found !\x1B[0;0m\n");	    exit(1);	    }	    fgetc(plik);	if (ferror (plik)) {	    if (multi<3) {	    fprintf(stderr,"\x1B[1;31m%s\x1B[0;31m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");fprintf(stderr,": ");	    fprintf(stderr,"Is a directory !\x1B[0;0m\n");	    }	    kod=1;	    dir=1;	    fclose(plik);	}		if (dir==0) {	    fseek(plik,0,SEEK_END);	    if (ftell(plik)>4) {	    rewind(plik);	    detect_image();	    } else {	    if (multi<3) {	    fprintf(stderr,"\x1B[1;31m%s\x1B[0;31m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");fprintf(stderr,": ");	    fprintf(stderr,"File size is %i b !\x1B[0;0m\n",(int)ftell(plik));	    }	    rewind(plik);	    	    }	}	if (kod==0){        fullscr=0;	grey=0;	    fprintf(stderr,"\x1B[1;30m%s\x1B[0;0m",mee);	    for (x=strlen(mee);x<16;x++) fprintf(stderr," ");	    fprintf(stderr,": ");	    	if (YU12==0) fprintf(stderr,"press \x1B[0;38mS\x1B[0;0m to save in ZMG format\n"); 	    else 	    fprintf(stderr,"press \x1B[0;38mS\x1B[0;0m to save in TGA format\n");	if (is_matrox==1) {	mga_size();	draw_image(image_x,image_y);	if (start_zoom == 1)	    mga_fs();	     	} else {	if ((start_zoom == 1) && (image_x<fb_vinfo.xres) && (image_y<fb_vinfo.yres))	   {	     fb_fs();	   } else 	draw_image_fb();	}	if (iksy==0) wait_key(argc); else wait_x_key();	}	if (dir==0) fclose(plik);	kod=1;	}	mga_uninit();        if (is_matrox==0) clear_bottom(); else mga_uninit();	fprintf(stderr,"\n");    if (fb_vinfo.bits_per_pixel==8 && is_matrox==0) {        restore_pal();	}	shutdown();	return 0;}	

⌨️ 快捷键说明

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