标题: 支持重载的控制台图显工具imaged.exe [打印本页]
作者: happy886rr 时间: 2017-2-6 22:22 标题: 支持重载的控制台图显工具imaged.exe
image大名鼎鼎,无人不晓。而imaged.exe是作为向image致敬的产品。支持你无法想象的多得多参数杂糅。专注图像多参显示,且根据你输入的参数的不同,做出不同的函数重载,输几个参数都行,不强求,非常自然。专为论坛、贴吧中喜欢制作批处理游戏的高端玩家打造。能够随意缩放图像尺寸,任意角度显示,图像裁剪...,让你的批处理游戏美轮美奂。非常严谨的错误反馈,一点小错都会报出英文说明,让严格贯穿始终。同时为了体积,使用了VS的神优化,只有10KB方便下载。- IMAGED.EXE
-
- 摘要:
- =============================================================================
- CMD控制台图片显示工具,支持bmp、png、gif、jpg、jpeg、tiff、exif、ico等多种
- 图片显示,包括12种参数自由设定,支持图片旋转、缩小、透明显示等特效。
- =============================================================================
-
- 下载:[attach]10407[/attach]
- 用法:
- -----------------------------------------------------------------------------
- imaged [options] {arguments}...
- -----------------------------------------------------------------------------
- BASE:
- [file] [cmd_x] [cmd_y] [cmd_with] [cmd_high]
- [src_x] [src_y] [src_with] [src_high]
- [rot_x] [rot_y] [rot_angle] //Draw an image
- OTHER:
- /help Show help information
- /hide Hide the cursor
- /show Show the cursor
- /clean [x] [y] [with] [high] //Clear the image
- -----------------------------------------------------------------------------
-
- 示例:
- -----------------------------------------------------------------------------
- imaged test.png 0 0 100 100 0 0 100 100 50 50 30 //将test.png旋转30度显示
- -----------------------------------------------------------------------------
-
- 备注:
- -----------------------------------------------------------------
- CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY
- -----------------------------------------------------------------
- imaged [options] {arguments}...
- -----------------------------------------------------------------
- BASE:
- [file] [cmd_x] [cmd_y] [cmd_with] [cmd_high]
- [src_x] [src_y] [src_with] [src_high]
- [rot_x] [rot_y] [rot_angle] Draw an image
- OTHER:
- /help Show help information
- /hide Hide the cursor
- /show Show the cursor
- /clean [x] [y] [with] [high] Clear the image
- -----------------------------------------------------------------
- 2017-02-06, VERSION 1.0"
复制代码
仅支持VS2010编译
原创代码:- /*
- CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
- IMAGED.EXE
- */
-
- #include <stdio.h>
- #include <Windows.h>
- #include <gdiplus.h>
- #pragma comment(lib, "GdiPlus.lib")
-
- //使用GDI+
- using namespace Gdiplus;
-
- //定义帮助说明
- #define HELP_INFORMATION "\
- -----------------------------------------------------------------\n\
- CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY\n\
- -----------------------------------------------------------------\n\
- imaged [options] {arguments}...\n\
- -----------------------------------------------------------------\n\
- BASE:\n\
- [file] [cmd_x] [cmd_y] [cmd_with] [cmd_high]\n\
- [src_x] [src_y] [src_with] [src_high]\n\
- [rot_x] [rot_y] [rot_angle] Draw an image\n\
- OTHER:\n\
- /help Show help information\n\
- /hide Hide the cursor\n\
- /show Show the cursor\n\
- /clean [x] [y] [with] [high] Clear the image\n\
- -----------------------------------------------------------------\n\
- 2017-02-03, VERSION 1.0"
-
- /***************定义全局变量*************/
- //定义关键词目
- #define SENSITIVE_NUM 6
- static const char* SENSITIVE_WORDS[]={"/HIDE", "/SHOW", "/CLEAN", "/HELP", "/H", "/?"};
- static int PRIVATIVE_PAR[11]={0};
-
- /***************功能函数群***************/
- //转码款字符
- WCHAR* L(const CHAR* str)
- {
- if(!str){return NULL;}
- int wLen=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0);
- WCHAR* wstr=(WCHAR*)malloc(sizeof(WCHAR)*wLen + 1);
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, wstr, wLen);
- wstr[wLen]='\0';
- return wstr;
- }
- //识别关键词
- int itifyWORDS(const char* strARGV)
- {
- int SN;
- for(SN=0; SN<SENSITIVE_NUM; SN++){
- char *op=(char*)strARGV, *kp=(char*)SENSITIVE_WORDS[SN];
- while(*kp!='\0'){
- if( (('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp) ){break;}
- op++;kp++;
- }
- if( (*kp=='\0') && (*op==' '||*op=='\t'||*op=='\r'||*op=='\n'||*op=='\0') ){return SN;}
- }
- return -1;
- }
- //显示光标
- BOOL DispyCursor(int size,bool mode)
- {
- CONSOLE_CURSOR_INFO cinfo ={(DWORD)size, mode};
- return SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cinfo);
- }
- //开关解析函数
- void OptRE(HWND hCMD, HDC hDC, int argc, char** argv)
- {
- //计算有效参数数目
- int oargc=argc-1;
- if(oargc==0){
- //无参数,则抛出使用说明
- fputs(HELP_INFORMATION, stderr);
- exit(1);
- }
-
- //参数接收针
- char** oargv=argv;
-
- //识别关键词
- int SN=itifyWORDS(argv[1]);
- if(SN!=-1){
- //执行基本命令
- switch(SN)
- {
- case 0:
- case 1:
- ///HIDE||SHOW
- DispyCursor((DWORD)25, (SN==0)?FALSE:TRUE);
- break;
-
- case 2:
- ///CLEAN
- if(oargc!=5){
- InvalidateRect(hCMD, NULL, FALSE);
- }else{
- RECT rc={atoi(argv[2]), atoi(argv[3]), atoi(argv[2])+atoi(argv[4]), atoi(argv[3])+atoi(argv[5])};
- InvalidateRect(hCMD, &rc, FALSE);
- }
- break;
-
- default:
- ///HELP
- fputs(HELP_INFORMATION, stderr);
- exit(0);
- }
-
- }else{
-
- //读取图像
- Image* srcIMG=NULL;
- if((srcIMG=Image::FromFile(L(argv[1])))==NULL){
- fputs("Read the image failed", stderr);
- exit(1);
- }
-
- int anum;
- for(anum=0; anum<11; anum++){
- if(anum+2<=oargc){
- PRIVATIVE_PAR[anum]=atoi(argv[anum+2]);
- }
- if ((anum==2||anum==6) && (PRIVATIVE_PAR[anum]==0)){
- PRIVATIVE_PAR[anum]=srcIMG->GetWidth();
- }else if((anum==3||anum==7) && (PRIVATIVE_PAR[anum]==0)){
- PRIVATIVE_PAR[anum]=srcIMG->GetHeight();
- }
- }
-
- //旋转矩阵
- Matrix matri;
- matri.Reset();
- matri.RotateAt((float)PRIVATIVE_PAR[10], PointF((float)PRIVATIVE_PAR[8], (float)PRIVATIVE_PAR[9]));
-
- //创建graph
- Graphics graph(hDC);
- graph.SetTransform(&matri);
-
- //绘制图像
- Status s=graph.DrawImage(srcIMG, Rect(PRIVATIVE_PAR[0],PRIVATIVE_PAR[1],PRIVATIVE_PAR[2],PRIVATIVE_PAR[3]), PRIVATIVE_PAR[4],PRIVATIVE_PAR[5],PRIVATIVE_PAR[6],PRIVATIVE_PAR[7], UnitPixel);
- if(s!=Ok){
- fputs("Drawing the image failed", stderr);
- exit(1);
- }
- }
- }
-
- /*************MAIN主函数入口*************/
- int main(int argc, char** argv)
- {
- //初始化Gdiplus
- ULONG_PTR gdipludToken;
- GdiplusStartupInput gdiplusInput;
- GdiplusStartup(&gdipludToken,&gdiplusInput,NULL);
-
- //获取CMD窗口句柄
- HWND hCMD=GetConsoleWindow();
- HDC hDC =GetDC(hCMD);
-
- //解析开关
- OptRE(hCMD, hDC, argc, argv);
-
- //释放DC兼顾刷新
- ReleaseDC(hCMD, hDC);
- DeleteDC(hDC);
-
- //关闭Gdiplus
- GdiplusShutdown(gdipludToken);
- return 0;
- }
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |