找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 9227|回复: 0

支持重载的控制台图显工具imaged.exe

[复制链接]
发表于 2017-2-6 22:22:19 | 显示全部楼层 |阅读模式
image大名鼎鼎,无人不晓。而imaged.exe是作为向image致敬的产品。支持你无法想象的多得多参数杂糅。专注图像多参显示,且根据你输入的参数的不同,做出不同的函数重载,输几个参数都行,不强求,非常自然。专为论坛、贴吧中喜欢制作批处理游戏的高端玩家打造。能够随意缩放图像尺寸,任意角度显示,图像裁剪...,让你的批处理游戏美轮美奂。非常严谨的错误反馈,一点小错都会报出英文说明,让严格贯穿始终。同时为了体积,使用了VS的神优化,只有10KB方便下载。
  1. IMAGED.EXE

  2. 摘要:
  3. =============================================================================
  4. CMD控制台图片显示工具,支持bmp、png、gif、jpg、jpeg、tiff、exif、ico等多种
  5. 图片显示,包括12种参数自由设定,支持图片旋转、缩小、透明显示等特效。
  6. =============================================================================

  7. 下载:
  8. 用法:
  9. -----------------------------------------------------------------------------
  10. imaged [options] {arguments}...
  11. -----------------------------------------------------------------------------
  12. BASE:
  13.     [file]  [cmd_x] [cmd_y] [cmd_with] [cmd_high]
  14.             [src_x] [src_y] [src_with] [src_high]
  15.             [rot_x] [rot_y] [rot_angle]        //Draw an image
  16. OTHER:
  17.     /help   Show help information
  18.     /hide   Hide the cursor
  19.     /show   Show the cursor
  20.     /clean  [x] [y] [with] [high]              //Clear the image
  21. -----------------------------------------------------------------------------

  22. 示例:
  23. -----------------------------------------------------------------------------
  24. imaged test.png 0 0 100 100 0 0 100 100 50 50 30    //将test.png旋转30度显示
  25. -----------------------------------------------------------------------------

  26. 备注:
  27. -----------------------------------------------------------------
  28. CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY
  29. -----------------------------------------------------------------
  30. imaged [options] {arguments}...
  31. -----------------------------------------------------------------
  32. BASE:
  33.     [file]  [cmd_x] [cmd_y] [cmd_with] [cmd_high]
  34.             [src_x] [src_y] [src_with] [src_high]
  35.             [rot_x] [rot_y] [rot_angle]        Draw an image
  36. OTHER:
  37.     /help   Show help information
  38.     /hide   Hide the cursor
  39.     /show   Show the cursor
  40.     /clean  [x] [y] [with] [high]              Clear the image
  41. -----------------------------------------------------------------
  42. 2017-02-06, VERSION 1.0"
复制代码
仅支持VS2010编译
原创代码:
  1. /*
  2.         CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
  3.         IMAGED.EXE
  4. */

  5. #include <stdio.h>
  6. #include <Windows.h>
  7. #include <gdiplus.h>
  8. #pragma comment(lib, "GdiPlus.lib")

  9. //使用GDI+
  10. using namespace Gdiplus;

  11. //定义帮助说明
  12. #define HELP_INFORMATION "\
  13. -----------------------------------------------------------------\n\
  14. CONSOLE IMAGE DISPLAY TOOL, COPYRIGHT@2017~2019 BY HAPPY\n\
  15. -----------------------------------------------------------------\n\
  16. imaged [options] {arguments}...\n\
  17. -----------------------------------------------------------------\n\
  18. BASE:\n\
  19.     [file]  [cmd_x] [cmd_y] [cmd_with] [cmd_high]\n\
  20.             [src_x] [src_y] [src_with] [src_high]\n\
  21.             [rot_x] [rot_y] [rot_angle]        Draw an image\n\
  22. OTHER:\n\
  23.     /help   Show help information\n\
  24.     /hide   Hide the cursor\n\
  25.     /show   Show the cursor\n\
  26.     /clean  [x] [y] [with] [high]              Clear the image\n\
  27. -----------------------------------------------------------------\n\
  28. 2017-02-03, VERSION 1.0"

  29. /***************定义全局变量*************/
  30. //定义关键词目
  31. #define            SENSITIVE_NUM    6
  32. static const char* SENSITIVE_WORDS[]={"/HIDE", "/SHOW", "/CLEAN", "/HELP", "/H", "/?"};
  33. static       int   PRIVATIVE_PAR[11]={0};

  34. /***************功能函数群***************/
  35. //转码款字符
  36. WCHAR* L(const CHAR* str)
  37. {
  38.         if(!str){return NULL;}
  39.         int wLen=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0);
  40.         WCHAR* wstr=(WCHAR*)malloc(sizeof(WCHAR)*wLen + 1);
  41.         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, wstr, wLen);
  42.         wstr[wLen]='\0';
  43.         return wstr;
  44. }
  45. //识别关键词
  46. int itifyWORDS(const char* strARGV)
  47. {
  48.         int SN;
  49.         for(SN=0; SN<SENSITIVE_NUM; SN++){
  50.                 char *op=(char*)strARGV, *kp=(char*)SENSITIVE_WORDS[SN];
  51.                 while(*kp!='\0'){
  52.                         if( (('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp) ){break;}
  53.                         op++;kp++;
  54.                 }
  55.                  if( (*kp=='\0') && (*op==' '||*op=='\t'||*op=='\r'||*op=='\n'||*op=='\0') ){return SN;}
  56.         }                               
  57.         return -1;
  58. }
  59. //显示光标
  60. BOOL DispyCursor(int size,bool mode)
  61. {
  62.         CONSOLE_CURSOR_INFO cinfo ={(DWORD)size, mode};
  63.         return SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cinfo);         
  64. }
  65. //开关解析函数
  66. void OptRE(HWND hCMD, HDC hDC, int argc, char** argv)
  67. {
  68.         //计算有效参数数目
  69.         int oargc=argc-1;
  70.         if(oargc==0){
  71.                 //无参数,则抛出使用说明
  72.                 fputs(HELP_INFORMATION, stderr);
  73.                 exit(1);
  74.         }

  75.         //参数接收针
  76.         char** oargv=argv;
  77.        
  78.         //识别关键词
  79.         int SN=itifyWORDS(argv[1]);
  80.         if(SN!=-1){       
  81.                 //执行基本命令
  82.                 switch(SN)
  83.                 {
  84.                 case 0:
  85.                 case 1:
  86.                         ///HIDE||SHOW
  87.                         DispyCursor((DWORD)25, (SN==0)?FALSE:TRUE);
  88.                         break;

  89.                 case 2:
  90.                         ///CLEAN
  91.                         if(oargc!=5){
  92.                                 InvalidateRect(hCMD, NULL, FALSE);
  93.                         }else{
  94.                                 RECT rc={atoi(argv[2]), atoi(argv[3]), atoi(argv[2])+atoi(argv[4]), atoi(argv[3])+atoi(argv[5])};
  95.                                 InvalidateRect(hCMD,  &rc, FALSE);
  96.                         }
  97.                         break;

  98.                 default:
  99.                         ///HELP
  100.                         fputs(HELP_INFORMATION, stderr);
  101.                         exit(0);
  102.                 }

  103.         }else{
  104.                
  105.                 //读取图像
  106.                 Image*  srcIMG=NULL;
  107.                 if((srcIMG=Image::FromFile(L(argv[1])))==NULL){
  108.                         fputs("Read the image failed", stderr);
  109.                         exit(1);
  110.                 }
  111.                
  112.                 int anum;
  113.                 for(anum=0; anum<11; anum++){
  114.                         if(anum+2<=oargc){
  115.                                 PRIVATIVE_PAR[anum]=atoi(argv[anum+2]);
  116.                         }
  117.                         if      ((anum==2||anum==6) && (PRIVATIVE_PAR[anum]==0)){
  118.                                 PRIVATIVE_PAR[anum]=srcIMG->GetWidth();
  119.                         }else if((anum==3||anum==7) && (PRIVATIVE_PAR[anum]==0)){
  120.                                 PRIVATIVE_PAR[anum]=srcIMG->GetHeight();
  121.                         }
  122.                 }
  123.                
  124.                 //旋转矩阵
  125.                 Matrix  matri;
  126.                 matri.Reset();
  127.                 matri.RotateAt((float)PRIVATIVE_PAR[10], PointF((float)PRIVATIVE_PAR[8], (float)PRIVATIVE_PAR[9]));

  128.                 //创建graph
  129.                 Graphics graph(hDC);
  130.                 graph.SetTransform(&matri);
  131.                
  132.                 //绘制图像
  133.                 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);
  134.                 if(s!=Ok){
  135.                         fputs("Drawing the image failed", stderr);
  136.                         exit(1);
  137.                 }
  138.         }
  139. }

  140. /*************MAIN主函数入口*************/
  141. int main(int argc, char** argv)
  142. {
  143.         //初始化Gdiplus
  144.         ULONG_PTR gdipludToken;
  145.         GdiplusStartupInput gdiplusInput;
  146.         GdiplusStartup(&gdipludToken,&gdiplusInput,NULL);

  147.         //获取CMD窗口句柄
  148.         HWND hCMD=GetConsoleWindow();
  149.         HDC  hDC =GetDC(hCMD);

  150.         //解析开关
  151.         OptRE(hCMD, hDC, argc, argv);

  152.         //释放DC兼顾刷新
  153.         ReleaseDC(hCMD, hDC);
  154.         DeleteDC(hDC);

  155.         //关闭Gdiplus
  156.         GdiplusShutdown(gdipludToken);
  157.         return 0;
  158. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

参与人数 2技术 +2 收起 理由
Byaidu + 1 +1
freesoft00 + 1 +1

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 01:14 , Processed in 0.018392 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表