Asp组件高级入门与精通系列之三

asp中测试

 1   
 2'生成缩略   
 3On Error resume next   
 4set obj=server.CreateObject("flysoft.image")   
 5obj.LoadFromFile=server.MapPath("./love.bmp") '原始图片   
 6obj.Rate =0.5 '缩放比率 其中<1为缩小,>1为放大   
 7obj.OutputImgFile server.MapPath("./lovethumbmail_bmp.jpg") '生成结果图片   
 8if err.number<>0 then   
 9response.write Err.Description   
10end if 

'生成水印

 1   
 2'生成文字水印   
 3On Error resume next   
 4set obj=server.CreateObject("flysoft.image")   
 5obj.Rate = 0.5 '缩放比率 其中<1为缩小,>1为放大   
 6obj.MarkRotate = 25 '旋转角度   
 7obj.MaskText = "浪漫的情人节 祝天下有情人终成眷属" '要显示的文字   
 8obj.MaskTextFontName = "华文彩云" '字体设置   
 9obj.LoadFromFile =server.MapPath("./rose.bmp") '原始图片   
10obj.OutputTxtImgFile server.MapPath("./rose_txtimg.jpg") , vbBlack, 20, 50, 0, 400 '参数分别代表:生成的图片,字体的颜色,字体的宽度,字体的高度,最后两个参数指文字相对于原始图片左上角的坐标位置   
11if err.number<>0 then   
12response.write Err.Description   
13end if   

 1   
 2'生成图片水印   
 3On Error resume next   
 4set obj=server.CreateObject("flysoft.image")   
 5obj.Rate = 0.5 '缩放比率 其中<1为缩小,>1为放大   
 6obj.LoadFromFile = server.MapPath("./love.JPG") '原始图片   
 7obj.LoadFromMaskImgFile = server.MapPath("./rose_mark.bmp") '水印图片   
 8obj.OutputMarkImgFile server.MapPath("./lovemark.jpg"), 350, 350, 100 '生成结果图片 500,500为水印图片相对于原始图片左上角的坐标位置 最后的100是透明度 (0最透明,100不透明)   
 9if err.number<>0 then   
10response.write Err.Description   
11end if   

同时还作了性能测试

作者的机器配置是赛扬850,内存512机器上生成50张图片(缩略,文字水印,图片水印)用了7秒
机器配置是p4 2.4,内存1G 机器上生成50张图片(缩略,文字水印,图片水印)用了2秒

可以下载 www.applevb.com/flysoft.rarhttp://www.5ivb.net/

Published At
Categories with Web编程
Tagged with
comments powered by Disqus