使用aspimage组件仅需以下步骤:
建一个对象
设置若干属性
调用saveimage方法
以下代码举例说明如何在vbscript中使用aspimage组件,在这个例子中我们要建立一个渐进填充的字样为 "welcome to"的文字图片:
set image = server.createobject("aspimage.image")
rem set various font parameters
image.fontcolor = vbblack
image.italic = true
image.bold = true
image.fontname = "arial"
image.fontsize = 12
image.padsize = 10
rem calculate how big our text info is and set the image to this size
remthis has to be done since we want to fill the area with a gradient
strmessage = "welcome to"
image.maxx = image.textwidth (strmessage)
image.maxy = image.textheight (strmessage)
rem create a one way gradient
image.gradientoneway vbred, vbwhite, 0
rem print our string to the image
image.textout strmessage, image.x, image.y, false
rem set the filename and save
remnote: you should gen the filename dynamically for multiuser usage
image.filename = "d:.netpubwwwrootimagesmsg1.jpg"
if image.saveimage then
rem the image was saved so write the <img src> tag out for the browser to pick up
response.write "<img src="http://www.ddvip.net/web/asp/searches/"/images/msg1.jpg""><br>"
else
rem something happened and we couldn't save the image so just use an html header
remwe need to debug the script and find out what went wrong
response.write "<h2>welcome to</h2>
end if
通过使用saveimage方法我们可以得知图片是否已经正确保存了。一般导致图片不能正确保存的原因是图片的保存路径不合法或者对该路径没有写的权限。
gif animations
图片能被加载或进行处理,并且可以通过调用addimage方法将这些修改保存到一个活动顺序的动画中。在soianim.asp中有个简单的gif动画例子,这个文件已打包到aspimage的zip文件中。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器