找回密码
 加入
搜索
查看: 2199|回复: 1

[AU3基础] 这个水印程序,可不可以在水印出来的字体填充上一层颜色?

[复制链接]
发表于 2012-10-27 17:28:51 | 显示全部楼层 |阅读模式
Func shuiyin($pic, $savepic, $str, $NUMont = "宋体", $size = "12", $style = "正常", $right = 0, $top = 12, $color = 0xff0000ff, $shuiyinpic = "", $picx = "", $picy = "")
        If $str = "" Then

                $pc0 = StringLeft(@ComputerName, 4)

                If $pc0 = "pc-0" Then

                        $one = StringReplace(@ComputerName, "pc-0", "")

                        $str = $wb & $one & '号机'
                Else
                        $one = StringReplace(@ComputerName, "pc-", "")

                        $str = $wb & $one & '号机'

                EndIf

        EndIf
        If $NUMont = "" Then
                $NUMont = IniRead($ini, "水印配置", "字体", "")

        EndIf
        If $size = "" Then
                $size = IniRead($ini, "水印配置", "字体大小", "")

        EndIf
        If $style = "" Then
                $style = IniRead($ini, "水印配置", "字体类型", "")

        EndIf
        If $right = "" Then
                $right = IniRead($ini, "水印配置", "文字距离图片右边距", "")

        EndIf
        If $top = "" Then
                $top = IniRead($ini, "水印配置", "文字距离图片上边距", "")

        EndIf
        If $color = "" Then
                $color = IniRead($ini, "水印配置", "文字颜色", "")


        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)
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
        $hBrush = _GDIPlus_BrushCreateSolid($color)
        $hFormat = _GDIPlus_StringFormatCreate()
        $hFamily = _GDIPlus_FontFamilyCreate($NUMont)
        $hFont = _GDIPlus_FontCreate($hFamily, $size, $mystyle)
        $tLayout = _GDIPlus_RectFCreate($right, $top, 0, 0)
        $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $str, $hFont, $tLayout, $hFormat)
        _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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-26 20:15 , Processed in 0.352869 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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