int show_pic(aml_image_info_t* image,int flag) { int x_size, y_size, screen_width, screen_height; int x_pan, y_pan, x_offs, y_offs; static video_out_t vo={0}; char* name; int reset_vo = 0; if(!image->data){ return -1; } switch(flag){ case 0: name="fb"; break; case 1: name="gles"; break ; default: name="fb"; break; } if(vo.name == 0){ vo.name = name ; if(vo_cfg(&vo)!=VO_ERROR_OK) { printf("video out device invalid\n"); return -1; } vo_preinit(&vo); }else{ if(!strcmp(vo.name, name)) { /*match last vo*/ reset_vo = 0; }else{ reset_vo = 1; vo_uninit(&vo); vo.name = name ; if(vo_cfg(&vo)!=VO_ERROR_OK) { printf("video out device invalid\n"); return -1; } vo_preinit(&vo); } } vo_getCurrentRes(&vo,&screen_width, &screen_height); if(image->width < screen_width) x_offs = (screen_width - image->width) / 2; else x_offs = 0; if(image->height < screen_height) y_offs = (screen_height - image->height) / 2; else y_offs = 0; x_pan = 0; y_pan= 0; vo_display(&vo, image, x_pan, y_pan, x_offs, y_offs); return 0; }
int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"noclear", no_argument, 0, 'c'}, {"alpha", no_argument, 0, 'a'}, {"unhide", no_argument, 0, 'u'}, {"noinfo", no_argument, 0, 'i'}, {"stretch", no_argument, 0, 'f'}, {"colorstrech", no_argument, 0, 'k'}, {"delay", required_argument, 0, 's'}, {"enlarge", no_argument, 0, 'e'}, {"ignore-aspect", no_argument, 0, 'r'}, {"play_folder", required_argument, 0, 'd'}, {0, 0, 0, 0} }; int c, i; char* filelist=NULL; video_out_t vo={0}; vo.name="gles"; if(argc < 2) { help(argv[0]); fprintf(stderr, "Error: Required argument missing.\n"); return(1); } while((c = getopt_long_only(argc, argv, "hcauifks:er", long_options, NULL)) != EOF) { switch(c) { case 'a': opt_alpha = 1; break; case 'c': opt_clear = 0; break; case 's': opt_delay = atoi(optarg); break; case 'u': opt_hide_cursor = 0; break; case 'h': help(argv[0]); return(0); case 'i': opt_image_info = 0; break; case 'f': opt_stretch = 1; break; case 'k': opt_stretch = 2; break; case 'e': opt_enlarge = 1; break; case 'r': opt_ignore_aspect = 1; break; case 'd': filelist = create_filelist(optarg); break; } } #if 0 if(!argv[optind]) { fprintf(stderr, "Required argument missing! Consult %s -h.\n", argv[0]); return(1); } #endif if(vo_cfg(&vo)!=VO_ERROR_OK) { printf("video out device invalid\n"); exit(1); } vo_preinit(&vo); #ifndef WIN32 signal(SIGHUP, sighandler); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGSEGV, sighandler); signal(SIGTERM, sighandler); signal(SIGABRT, sighandler); if(opt_hide_cursor) { printf("\033[?25l"); fflush(stdout); } setup_console(1); #endif if(filelist) { filelist_t* pre=NULL; char* filename; while(enum_file(filelist,&pre,&filename)!=-1) { if(filename&&strlen(filename)>3) show_image(filename,&vo); } free_filelist(filelist); } else { for(i = optind; argv[i]; ) { int r = show_image(argv[i],&vo); if(!r) break; i += r; if(i < optind) i = optind; } } setup_console(0); if(opt_hide_cursor) { printf("\033[?25h"); fflush(stdout); } vo_uninit(&vo); return(0); }