#include #include #include #include #include"pixel_format.h" #include #include #include #include #include using namespace hgl; using namespace hgl::filesystem; using namespace hgl::util; bool sub_folder =false; const PixelFormat * pixel_fmt[4] ={nullptr,nullptr,nullptr,nullptr}; //选中格式 bool gen_mipmaps =false; //是否产生mipmaps bool use_color_key =false; //是否使用ColorKey uint8 color_key[3]; //ColorKey颜色 const PixelFormat *ParseParamFormat(const CmdParse &cmd,const os_char *flag,const PixelFormat *default_format) { OSString fmtstr; if(!cmd.GetString(flag,fmtstr))return(default_format); const PixelFormat *result=GetPixelFormat(fmtstr.c_str()); if(result)return(result); LOG_INFO(OS_TEXT("[FORMAT ERROR] Don't support ")+fmtstr+OS_TEXT(" format.")); return default_format; } void ParseParamFormat(const CmdParse &cmd) { //指定格式 pixel_fmt[0]=ParseParamFormat(cmd,OS_TEXT("/R:"), GetPixelFormat(ColorFormat::R8UN)); pixel_fmt[1]=ParseParamFormat(cmd,OS_TEXT("/RG:"), GetPixelFormat(ColorFormat::RG8UN)); pixel_fmt[2]=ParseParamFormat(cmd,OS_TEXT("/RGB:"), GetPixelFormat(ColorFormat::RGB565)); pixel_fmt[3]=ParseParamFormat(cmd,OS_TEXT("/RGBA:"), GetPixelFormat(ColorFormat::RGBA8UN)); for(uint i=0;i<4;i++) std::cout<name<\n" "\n" "Params:\n" "\t/s : proc sub-directory\n" "\n"; PrintFormatList(); return 0; } CmdParse cp(argc,argv); if(cp.Find(OS_TEXT("/s"))!=-1)sub_folder=true; //检测是否处理子目录 if(cp.Find(OS_TEXT("/mip"))!=-1)gen_mipmaps=true; //检测是否生成mipmaps ParamColorKey(cp); ParseParamFormat(cp); //检测推荐格式 ilInit(); double start_time=GetMicroTime(); double end_time; OSString cur_path; GetCurrentPath(cur_path); EnumFileConfig efc(cur_path); efc.find_name =OSString(argv[1]); efc.proc_file =true; efc.sub_folder =sub_folder; EnumConvertImage eci; eci.Enum(&efc); end_time=GetTime(); LOG_INFO(OS_TEXT("总计转换图片")+OSString(eci.GetConvertCount()) +OS_TEXT("张,总计耗时")+OSString(end_time-start_time)+OS_TEXT("秒")); ilShutDown(); return 0; }