#region ACN预处理程序参数(常用参数)
#PRE_Icon= ;图标,支持EXE,DLL,ICO
#PRE_OutFile= ;输出文件名
#PRE_OutFile_Type=exe ;文件类型
#PRE_Compression=4 ;压缩等级
#PRE_UseUpx=y ;使用压缩
#PRE_Res_Comment= ;程序注释
#PRE_Res_Description= ;详细信息
#PRE_Res_Fileversion= ;文件版本
#PRE_Res_FileVersion_AutoIncrement=p ;自动更新版本
#PRE_Res_LegalCopyright= ;版权
#PRE_Change2CUI=N ;修改输出的程序为CUI(控制台程序)
;#PRE_Res_Field=AutoIt Version|%AutoItVer% ;自定义资源段
;#PRE_Run_Tidy= ;脚本整理
;#PRE_Run_Obfuscator= ;代码迷惑
;#PRE_Run_AU3Check= ;语法检查
;#PRE_Run_Before= ;运行前
;#PRE_Run_After= ;运行后
;#PRE_UseX64=n ;使用64位解释器
;#PRE_Compile_Both ;进行双平台编译
#endregion ACN预处理程序参数(常用参数)
#cs ____________________________________
Au3 版本:
脚本作者:
电子邮件:
QQ/TM:
脚本版本:
脚本功能:
#ce _______________脚本开始_________________
#include<inet.au3>
#include <GDIPlus.au3>
Dim $var = 'abcdekmnpqstuvwxyzABCDEFJKLMNPQRSTUVWXYZ23456789'
For $i = 1 To StringLen($var)
;~ MsgBox(0, "", StringMid($var, $i, 1))
Dim $str = StringMid($var, $i, 1)
For $y = -40 To 40 Step 2
shuiyin(@ScriptDir & "\100.bmp", @ScriptDir & "\A" & $i & $y & $str & ".bmp", $str, $y, "Arial", 28, "正常", 30, 50, 0xFF000000, "", "", "")
Next
Next
;~ shuiyin(@ScriptDir & "\01.jpg", @ScriptDir & "\02.jpg", $f, "", "", "", "", "", "", @TempDir & "\gto250pic.gif", 10, 100)
;========================================================================================
;纯au3编写的图片添加文字水印的UDF___________gto250 2010.4.5
;参数:
; $nAngle:旋转角度
; $pic:需要添加水印的图片的路径
; eq:@ScriptDir & "\1.jpg"
; $savepic:水印添加后保存的路径
; eq:@ScriptDir & "\1.jpg"
; $str:添加的水印文字内容
; eq:"纯au3文字水印"
; $font:字体
; eq:"宋体"
; $size:字体大小 ;已经更改为按像素来计算
; eq:12
; $style:字体类型
; eq:正常、粗体、斜体、下划线、删除线
; $right:文字距离图片右边距
; eq:0
; $top:文字距离图片上边距
; eq:0
; $color:字体颜色
; eq:0xff0000ff
; $shuiyinpic:水印图片路径
; eq:@ScriptDir & "\1.jpg"
; $picx:水印图片放置的位置
; $picy=水印图片放置的位置
; eq:shuiyin(@ScriptDir&"\01.jpg",@ScriptDir&"\02.jpg",$f,"","","","","","",@TempDir & "\gto250pic.gif",10,100) ;#000000
;=========================================================================================
Func shuiyin($pic, $savepic, $str, $nAngle, $font = "宋体", $size = "25", $style = "正常", $right = 15, $top = 5, $color = 0xFF000000, $shuiyinpic = "", $picx = "", $picy = "")
If $str = "" Then
$str = "没有填写任何东西"
EndIf
If $font = "" Then
$font = "宋体"
EndIf
If $size = "" Then
$size = 12
EndIf
If $style = "" Then
$style = "正常"
EndIf
If $right = "" Then
$right = 0
EndIf
If $top = "" Then
$top = 0
EndIf
If $color = "" Then
$color = 0xff0000ff
EndIf
Switch $style
Case "正常"
$mystyle = 0
Case "粗体"
$mystyle = 1
Case "斜体"
$mystyle = 2
Case "下划线"
$mystyle = 4
Case "删除线"
$mystyle = 8
EndSwitch
_GDIPlus_Startup()
; Load image
$hImage = _GDIPlus_ImageLoadFromFile($pic) ;$pic=@ScriptDir & "\50x50.bmp"
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
$hBrush = _GDIPlus_BrushCreateSolid($color);返回实心画刷(Brush)对象句柄 $color = 0xFF000000 纯黑色
$hFormat = _GDIPlus_StringFormatCreate();创建字符串格式对象
$hFamily = _GDIPlus_FontFamilyCreate($font);创建字体族对象
$hFont = _GDIPlus_FontCreate($hFamily, $size, $mystyle, 2);创建字体对象 2 - 像素单位
$tLayout = _GDIPlus_RectFCreate($right, $top, 0, 0);创建 $tagGDIPRECTF(图形填充矩形) 结构
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $str, $hFont, $tLayout, $hFormat) ;测量字符串大小 [0] - 接收字符串矩形边界的 $tagGDIPRECTF 结构
$hMatrix = _GDIPlus_MatrixCreate() ;创建并初始化矩阵对象为单位矩阵 返回矩阵对象句柄
_GDIPlus_MatrixRotate($hMatrix, $nAngle, "False") ;旋转角度. 正值指定顺时针旋转. False - 向右旋转矩形 -----设置旋转的参数
_GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix) ;设置图像对象的世界坐标空间
_GDIPlus_GraphicsDrawStringEx($hGraphic, $str, $hFont, $aInfo[0], $hFormat, $hBrush);绘制字符串(使用数据结构).
If $shuiyinpic <> "" And $picx <> "" And $picy <> "" Then ;不为空则添加水印图片
$hImage1 = _GDIPlus_ImageLoadFromFile($shuiyinpic)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage1, $picx, $picy)
EndIf
_GDIPlus_ImageSaveToFile($hImage, $savepic) ;图像保存到文件.
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndFunc ;==>shuiyin
100.bmp为100*100像素的纯白图片。