BBSXP的 AspJpeg 水印函数

今天装了一个asp的bbs,很经典的BBSXP程序,最后一次玩还是高三的时候,如今大学都毕业了….

看了附件上传部分的代码,比我的WindsPhoto处理图片水印强很多,精华代码在这个函数,很有参考价值,贴出来学习一下。

Function JpegPersits
if SiteConfig("WatermarkType")=0 then
Jpeg.Canvas.Font.Color = Replace(SiteConfig("WatermarkFontColor"),"#","&h") '颜色
Jpeg.Canvas.Font.Family = SiteConfig("WatermarkFontFamily")         '字体
Jpeg.Canvas.Font.size = SiteConfig("WatermarkFontSize")         '大小
Jpeg.Canvas.Font.Bold = CBool(SiteConfig("WatermarkFontIsBold"))    '是否加粗
'Jpeg.Canvas.Font.ShadowXoffset = 10        '水印文字阴影向右偏移的像素值,输入负值则向左偏移
'Jpeg.Canvas.Font.ShadowYoffset = 10        '水印文字阴影向下偏移的像素值,输入负值则向右偏移
Title = SiteConfig("WatermarkText")
TitleWidth = Jpeg.Canvas.GetTextExtent(Title)
if Jpeg.Width<TitleWidth then exit function '图片比水印文字小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - TitleWidth) / 2
case "right"
PositionWidth= Jpeg.Width - TitleWidth - 10
end select
Jpeg.Canvas.Print PositionWidth, 10, Title
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif SiteConfig("WatermarkType")=1 then
Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg2.Open Server.MapPath(SiteConfig("WatermarkImage"))
Jpeg2Width=Jpeg2.OriginalWidth
Jpeg2Height=Jpeg2.OriginalHeight
if Jpeg.Width<Jpeg2Width or Jpeg.Height<Jpeg2Height*2 then exit function    '图片比水印图片小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - Jpeg2Width) / 2
case "right"
PositionWidth= Jpeg.Width - Jpeg2Width - 10
end select
select case SiteConfig("WatermarkHeightPosition")
case "top"
PositionHeight=10
case "center"
PositionHeight=(Jpeg.Height - Jpeg2Height) / 2
case "bottom"
PositionHeight= Jpeg.Height - Jpeg2Height - 10
end select
Jpeg.Canvas.DrawImage PositionWidth, PositionHeight, Jpeg2, 1, &HFFFFFF '透明度, 透明颜色
end if
End Function
%>

3 thoughts on “BBSXP的 AspJpeg 水印函数

发表评论

电子邮件地址不会被公开。 必填项已用*标注