这个水印程序,可不可以在水印出来的字体填充上一层颜色?
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, $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
页:
[1]