标题: 控制台印章制作工具stamp.exe [打印本页]
作者: happy886rr 时间: 2017-2-5 23:43 标题: 控制台印章制作工具stamp.exe
本帖最后由 happy886rr 于 2017-2-5 23:49 编辑
STAMP.EXE批之印。开源版采取免费发行策略,且只提供部分功能。更多高级功能比如存为透明png、高精度走样、图形水印、电子防伪、定制印框、定做字体、图形GUI界面、数论变换插值等请发短消息详谈。
开源版下载地址http://qiannao.com/file/wodewangpan798/68793990/
测试样张:
摘要:
=============================================================================
控制台印章绘制工具,多达12种自由参数,完美诠释“印”的艺术。几行命令即可让你
绘出专属印章。
=============================================================================
用法:
-----------------------------------------------------------------------------
stamp [options] {arguments}...
-----------------------------------------------------------------------------
/set-center [x] [y] 设置印章中心
/set-font [with] [high] [thin] [color] [fonts] 设置印章字体
/img-frame [with/2] [high/2] [thin] [color] [style] 设置印章框体
/img-text [string] [angle] [dangle] [r] [style] 设置印章正文
-----------------------------------------------------------------------------
示例:
-----------------------------------------------------------------------------
绘制古代方刻章
stamp /SET-CENTER 300 200 /IMG-FRAME 200 200 10 12 8
-----------------------------------------------------------------------------
备注:
/img-frame 中的[style]取值 (-1) ~ 8 代表10种不同框体
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/img-text 中的[style]取值 (-2) ~ 1 代表 4种不同文形
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/img-text 中的[angle]字体初始相位角、[dangle]字体间隔角、[r]字体环绕半径
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
十六色系:[color]取值 0 ~ 15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 { 0, 0, 0,RGB( 0, 0, 0)}, //黑色
1 { 0, 0,255,RGB( 0, 0,255)}, //蓝色
2 { 0,255, 0,RGB( 0,255, 0)}, //绿色
3 { 0,255,255,RGB( 0,255,255)}, //青色
4 {255, 0, 0,RGB(255, 0, 0)}, //红色
5 {238,130,238,RGB(238,130,238)}, //紫兰
6 {165, 42, 42,RGB(165, 42, 42)}, //棕色
7 {211,211,211,RGB(211,211,211)}, //浅灰
8 {169,169,169,RGB(169,169,169)}, //深灰
9 {173,216,230,RGB(173,216,230)}, //淡蓝
10 {144,238,144,RGB(144,238,144)}, //浅绿
11 {224,255,255,RGB(224,255,255)}, //淡青
12 {248, 29, 56,RGB(248, 29, 56)}, //亮红
13 {255, 0,255,RGB(255, 0,255)}, //洋紫
14 {255,255, 0,RGB(255,255, 0)}, //黄色
15 {255,255,255,RGB(255,255,255)} //白色
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-02-05
原创代码:- /*
- CONSOLE STAMP TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
- STAMP.EXE
- */
-
- #include <stdio.h>
- #include <Windows.h>
-
- //定义圆周率
- #define FPU_PI 3.1415926535897932
-
- //申明函数
- HWND WINAPI GetConsoleWindow();
-
- //定义帮助说明
- #define HELP_INFORMATION "\
- -----------------------------------------------------------------\n\
- CONSOLE STAMP TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0\n\
- -----------------------------------------------------------------\n\
- stamp [options] {arguments}...\n\
- -----------------------------------------------------------------\n\
- /set-center [x] [y]\n\
- /set-font [with/2] [high/2] [thin] [color] [fonts]\n\
- /img-frame [with/2] [high/2] [thin] [color] [style]\n\
- /img-text [string] [angle] [dangle] [r] [style]\n\
- -----------------------------------------------------------------\n\
- 2017-02-03"
-
- /***************定义全局变量*************/
- //定义字体属性
- static char* pFONT="@system";
- static int CENTERX=0, CENTERY=0, pWITH=30, pHEIGHT=100, pTHIN=10, pCOLOR=12;
- //定义关键词目
- #define SENSITIVE_NUM 7
- static const char* SENSITIVE_WORDS[]={"/SET-CENTER", "/SET-FONT", "/IMG-FRAME", "/IMG-TEXT", "/HELP", "/H", "/?"};
- static const char SENSITIVE_ARGVS[]={2,5,5,5,0,0,0};
- //定义十六色系
- static const COLORREF PRGB[16]=
- {
- RGB( 0, 0, 0), //黑色
- RGB( 0, 0,255), //蓝色
- RGB( 0,255, 0), //绿色
- RGB( 0,255,255), //青色
- RGB(255, 0, 0), //红色
- RGB(238,130,238), //紫兰
- RGB(165, 42, 42), //棕色
- RGB(211,211,211), //浅灰
- RGB(169,169,169), //深灰
- RGB(173,216,230), //淡蓝
- RGB(144,238,144), //浅绿
- RGB(224,255,255), //淡青
- RGB(248, 29, 56), //亮红
- RGB(255, 0,255), //洋紫
- RGB(255,255, 0), //黄色
- RGB(255,255,255) //白色
- };
-
- /***************功能函数群***************/
- //度转弧度
- double FPU_torad(double x)
- {
- return x*FPU_PI/180;
- }
- //正弦函数
- double FPU_sin(double x)
- {
- double FPU_RET;
- __asm__
- (
- "fsin\n"
- : "=t" (FPU_RET)
- : "0" (x)
- );
- return FPU_RET;
- }
- //余弦函数
- double FPU_cos(double x)
- {
- double FPU_RET;
- __asm__
- (
- "fcos\n"
- : "=t" (FPU_RET)
- : "0" (x)
- );
- return FPU_RET;
- }
- //开方函数
- double FPU_sqrt(double x)
- {
- double FPU_RET;
- __asm__
- (
- "fsqrt\n"
- : "=t" (FPU_RET)
- : "0" (x)
- );
- return FPU_RET;
- }
- //识别关键词
- int itifyWORDS(const char* strARGV)
- {
- int i, 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;
- }
- //绘制印框
- void drawFRAME(HDC hDC, int frameWITH_HALF, int frameHEIGHT_HALF, int frameTHIN, int frameCOLOR, int shapeMODE)
- {
- HPEN hPEN=CreatePen(PS_SOLID, frameTHIN, PRGB[frameCOLOR]);
- SelectObject(hDC, hPEN);
-
- //建空画刷
- HBRUSH mBRUSH=(shapeMODE==-1||shapeMODE==2)?CreateSolidBrush(PRGB[frameCOLOR]):GetStockObject(NULL_BRUSH);
- SelectObject(hDC, mBRUSH);
-
- //背景透明
- SetBkMode(hDC,TRANSPARENT);
-
- if (shapeMODE==-1){
- //绘制实心椭圆
- Ellipse( hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
-
- }else if(shapeMODE==0){
- //绘制椭圆框体
- Ellipse( hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
-
- }else if(shapeMODE==1||shapeMODE==2){
- //绘制矩形框体
- Rectangle(hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
-
- }else if(3<=shapeMODE &&shapeMODE<=8){
- //绘制十字矩形
- Rectangle(hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX ,CENTERY+frameHEIGHT_HALF);
- Rectangle(hDC, CENTERX ,CENTERY-frameHEIGHT_HALF,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
-
- //设置实(空)心画刷
- mBRUSH=(shapeMODE==7||shapeMODE==8)?CreateSolidBrush(PRGB[frameCOLOR]):GetStockObject(NULL_BRUSH);
- SelectObject(hDC, mBRUSH);
-
- if(shapeMODE>3){
- if(shapeMODE==4||shapeMODE==6||shapeMODE==7||shapeMODE==8){
- if (shapeMODE==7){
- Rectangle(hDC, CENTERX-frameWITH_HALF,CENTERY,CENTERX,CENTERY+frameHEIGHT_HALF);
- }else if(shapeMODE==8){
- Rectangle(hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX-frameTHIN/2,CENTERY-frameTHIN/2);
- }else {
- Rectangle(hDC, CENTERX-frameWITH_HALF,CENTERY-frameHEIGHT_HALF,CENTERX,CENTERY);
- }
- }
- if(shapeMODE==5||shapeMODE==6||shapeMODE==8){
- if(shapeMODE==8){
- Rectangle(hDC, CENTERX+frameTHIN/2,CENTERY+frameTHIN/2,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
- }else{
- Rectangle(hDC, CENTERX,CENTERY,CENTERX+frameWITH_HALF,CENTERY+frameHEIGHT_HALF);
- }
- }
- }
- }
-
- //清除对象
- DeleteObject(hPEN);
- DeleteObject(mBRUSH);
- return;
- }
- //绘制印文(心符)
- void drawTEXT(HDC hDC, char* pSTRING, int pANGLE, int pDANGLE, int RADIUS, int shapeMODE)
- {
- LOGFONTA fontSRC={
- pHEIGHT, //字体高度
- pWITH, //字体宽度
- pANGLE*10, //显示角度(3600进制)
- 0, //nOrientation
- pTHIN, //字体磅数
- FALSE, //非倾斜体
- FALSE, //无下划线
- FALSE, //无删除线
- DEFAULT_CHARSET, //默认字集
- OUT_DEFAULT_PRECIS, //输出精度
- CLIP_DEFAULT_PRECIS,//裁减精度
- DEFAULT_QUALITY, //nQuality
- DEFAULT_PITCH, //nPitchAndFamily
- "" //字体
- };
- //临时辅助指针
- LOGFONTA* pSRC=&fontSRC;
- //赋值字体名称
- strcpy(pSRC->lfFaceName, pFONT);
- //创建属性字体
- HFONT hFONT=CreateFontIndirectA(pSRC);
- //选择字体属性
- SelectObject(hDC, hFONT);
- //设置背景透明
- SetBkMode(hDC,TRANSPARENT);
- //设置字体颜色
- SetTextColor(hDC, PRGB[pCOLOR]);
-
- if(shapeMODE==-2 ||shapeMODE==-1 ||shapeMODE==0 ||shapeMODE==1){
- //绘制环形文本
- byte *pTEXT=(byte*)pSTRING, *p=(byte*)calloc(3, sizeof(byte));
- for(; *pTEXT!='\0'; pTEXT++,pANGLE+=pDANGLE){
- p[0]=*pTEXT, p[1]=((*pTEXT)<0x80)?0:*(++pTEXT);
-
- pSRC->lfEscapement=(shapeMODE==0) ?pANGLE*10-900 :(shapeMODE==-1) ?pANGLE*10+900:0;
- hFONT=CreateFontIndirectA(pSRC);
- SelectObject(hDC, hFONT);
- if(shapeMODE==1){
- TextOutA(hDC, CENTERX+RADIUS*FPU_cos(FPU_torad(pANGLE))-pWITH*FPU_sqrt(2)*FPU_cos(FPU_torad(pSRC->lfEscapement/10)-FPU_PI/4), CENTERY-RADIUS*FPU_sin(FPU_torad(pANGLE))+pWITH*FPU_sqrt(2)*FPU_sin(FPU_torad(pSRC->lfEscapement/10)-FPU_PI/4), pSTRING, lstrlenA(pSTRING));
- DeleteObject(hFONT);
- return;
- }
- TextOutA(hDC, CENTERX+RADIUS*FPU_cos(FPU_torad(pANGLE))-pWITH*FPU_sqrt(2)*FPU_cos(FPU_torad(pSRC->lfEscapement/10)-FPU_PI/4), CENTERY-RADIUS*FPU_sin(FPU_torad(pANGLE))+pWITH*FPU_sqrt(2)*FPU_sin(FPU_torad(pSRC->lfEscapement/10)-FPU_PI/4), (char*)p, lstrlenA((char*)p));
- }
- }
-
- //清理对象
- DeleteObject(hFONT);
- return;
- }
- //开关解析函数
- void OptRE(HDC hDC, int argc, char** argv)
- {
- //计算有效参数数目
- int oargc=argc-1, anum;
- if(oargc==0){
- //无参数,则抛出使用说明
- fputs(HELP_INFORMATION, stderr);
- exit(1);
- }
-
- //参数接收针
- char** oargv=argv;
-
- //参数累加器
- int i=0;
-
- //开启主循环
- while((++i)<=oargc){
-
- int SN=itifyWORDS(argv[i]);
- if(SN!=-1){
- if(i+SENSITIVE_ARGVS[SN]>oargc){
- //缺少必要参数
- fprintf(stderr, "The option '%s' needs %d parameters\n", argv[i], SENSITIVE_ARGVS[SN]);
- exit(1);
- }
- for(anum=1; anum<=SENSITIVE_ARGVS[SN]; anum++){
- if(oargv[i+anum][0]==SENSITIVE_WORDS[0][0]){
- //缺少必要参数
- fprintf(stderr, "Only %d parameters, the option '%s' needs %d parameters\n", anum-1, argv[i], SENSITIVE_ARGVS[SN]);
- exit(1);
- }
- }
-
- //执行开关命令
- switch(SN)
- {
- case 0:
- //set-center
- CENTERX=atoi(argv[i+1]), CENTERY=atoi(argv[i+2]);
- break;
-
- case 1:
- //set-font
- pWITH=atoi(argv[i+1]), pHEIGHT=atoi(argv[i+2]), pTHIN=atoi(argv[i+3]), pCOLOR=atoi(argv[i+4]), pFONT=argv[i+5];
- break;
-
- case 2:
- //img-frame
- drawFRAME(hDC, atoi(argv[i+1]), atoi(argv[i+2]), atoi(argv[i+3]), atoi(argv[i+4]), atoi(argv[i+5]));
- break;
-
- case 3:
- //img-text
- drawTEXT( hDC, argv[i+1], atoi(argv[i+2]), atoi(argv[i+3]), atoi(argv[i+4]), atoi(argv[i+5]));
- break;
-
- default:
- //使用说明
- fputs(HELP_INFORMATION, stderr);
- exit(1);
- }
- i+=SENSITIVE_ARGVS[SN];
-
- //无法识别的参数
- }else{
- fprintf(stderr, "An error occurred near '%s'\n", argv[i]);
- exit(1);
- }
- }
- }
-
- /*************MAIN主函数入口*************/
- int main(int argc, char** argv)
- {
- //获取CMD窗口句柄
- HWND hCMD=GetConsoleWindow();
- HDC hDC =GetDC(hCMD);
-
- //解析开关
- OptRE(hDC, argc, argv);
-
- //释放DC兼顾刷新
- ReleaseDC(hCMD, hDC);
- DeleteDC(hDC);
- return 0;
- }
复制代码
批处理调用演示- @echo off
- ::***************************************************************************
- title 批之印模板二
- mode con cols=120 lines=35
- for /f "tokens=1-10" %%a in ('more +12 "%~f0"') do (
- stamp /SET-CENTER %%a %%b /IMG-FRAME 200 200 10 %%j 0 /IMG-FRAME 190 190 3 %%j 0 /SET-FONT %%i 100 10 %%j %%c /IMG-TEXT %%d 0 0 0 1 /SET-FONT 27 100 600 %%j %%c /IMG-TEXT %%e 203 -32 136 %%h /SET-FONT 9 22 600 %%j %%c /IMG-TEXT %%f 231 0 112 1 /SET-FONT 7 20 600 %%j %%c /IMG-TEXT %%g -15 -5 180 0
- )
- pause>nul
- exit /b
- ::***************************************************************************
-
-
- 500 200 宋体 ★ 北京圣天香有限公司 中华人民共和国经贸 BJLUNUAPICHTANZHULIZHNZHANG 0 50 4
- 230 260 宋体 ★ 山东维拉雅服饰 中华人民共和国经贸 SDYANJIUUEYIWAHUANNSHUXUANZZHANG 0 50 13
- 500 380 宋体 ★ 阿里巴巴集团专章 中华人民共和国经贸 ALBBNUAPICHTANZHULIZHNZHANG 0 50 14
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |