简单生活

Simple life , it's as easy as 1,2,3...

BBSXP的aspjpeg水印函数

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

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

ASP代码
  1. Function JpegPersits  
  2.     if SiteConfig("WatermarkType")=0 then  
  3.         Jpeg.Canvas.Font.Color = Replace(SiteConfig("WatermarkFontColor"),"#","&h"'颜色  
  4.         Jpeg.Canvas.Font.Family = SiteConfig("WatermarkFontFamily")         '字体  
  5.         Jpeg.Canvas.Font.size = SiteConfig("WatermarkFontSize")         '大小  
  6.         Jpeg.Canvas.Font.Bold = CBool(SiteConfig("WatermarkFontIsBold"))    '是否加粗  
  7.         'Jpeg.Canvas.Font.ShadowXoffset = 10        '水印文字阴影向右偏移的像素值,输入负值则向左偏移  
  8.         'Jpeg.Canvas.Font.ShadowYoffset = 10        '水印文字阴影向下偏移的像素值,输入负值则向右偏移  
  9.         Title = SiteConfig("WatermarkText")   
  10.         TitleWidth = Jpeg.Canvas.GetTextExtent(Title)  
  11.         if Jpeg.Width<TitleWidth then exit function '图片比水印文字小,则不加水印  
  12.         select case SiteConfig("WatermarkWidthPosition")  
  13.         case "left"  
  14.             PositionWidth=10  
  15.         case "center"  
  16.             PositionWidth=(Jpeg.Width - TitleWidth) / 2  
  17.         case "right"  
  18.             PositionWidth= Jpeg.Width - TitleWidth - 10  
  19.         end select  
  20.         Jpeg.Canvas.Print PositionWidth, 10, Title  
  21.         '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  
  22.     elseif SiteConfig("WatermarkType")=1 then  
  23.         Set Jpeg2 = Server.CreateObject("Persits.Jpeg")  
  24.         Jpeg2.Open Server.MapPath(SiteConfig("WatermarkImage"))  
  25.         Jpeg2Width=Jpeg2.OriginalWidth  
  26.         Jpeg2Height=Jpeg2.OriginalHeight  
  27.         if Jpeg.Width<Jpeg2Width or Jpeg.Height<Jpeg2Height*2 then exit function    '图片比水印图片小,则不加水印  
  28.         select case SiteConfig("WatermarkWidthPosition")  
  29.         case "left"  
  30.             PositionWidth=10  
  31.         case "center"  
  32.             PositionWidth=(Jpeg.Width - Jpeg2Width) / 2  
  33.         case "right"  
  34.             PositionWidth= Jpeg.Width - Jpeg2Width - 10  
  35.         end select  
  36.         select case SiteConfig("WatermarkHeightPosition")  
  37.         case "top"  
  38.             PositionHeight=10  
  39.         case "center"  
  40.             PositionHeight=(Jpeg.Height - Jpeg2Height) / 2  
  41.         case "bottom"  
  42.             PositionHeight= Jpeg.Height - Jpeg2Height - 10  
  43.         end select  
  44.         Jpeg.Canvas.DrawImage PositionWidth, PositionHeight, Jpeg2, 1, &HFFFFFF '透明度, 透明颜色  
  45.     end if  
  46. End Function  
  47. %>  
« WindsPhoto 更新全记录“ActivePlugin_插件ID名称”函数是必须的 »
    Gravatar头像
  • quote 1.宅男
  • 2008-7-20 2:07:24 回复
  • 看到吓啊吓死了......专业人士啊
    Gravatar头像
  • quote 2.好好爱
  • 2008-7-27 10:58:38 回复
  • 你好!请教你这个代码高亮插件是什么插件?
    狼的旋律 于 2008-7-27 13:07:21 回复
    FCK的插件

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关注我

最新评论及回复

赞助商链接

Powered By Z-Blog 1.8 Walle Build 91204
Copyright © 2007-2011 Wilf.cn. Some Rights Reserved