asp水印组件之AspJpeg的结合代码实例(3)
%>
10、如何用AspJpeg组件进行图片切割?
AspJpeg 1.1+ is also capable of cutting off edges from, or cropping, the resultant thumbnails via the method Crop(x0, y0, x1, y1). The size of the cropped image is specified by the coordinates of the upper-left and lower-right corners within the resultant thumbnail, not the original large image.
<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath("t.jpg")
jpeg.Crop 20, 30, jpeg.Width - 20, jpeg.Height - 10
jpeg.save Server.mappath("tt.jpg")
Response.write("<img src=tt.jpg>")
%>
11、如何用AspJpeg组件创建安全码?
创建安全码原理上和创建水印差不多。
<%
function make_randomize(max_len,w_n) 'max_len 生成长度,w_n:0 可能包含字母,1:只为数字
randomize
for intcounter=1 to max_len
whatnext=int((1-0+1)*rnd+w_n)
if whatnext=0 then
upper=122
lower=97
else
upper=57
lower=48
end if
strnewpass=strnewpass & chr(int((upper-lower+1)*rnd)+lower)
next
make_randomize=strnewpass
end function
'生成安全码的图片。
random_num=make_randomize(4,1) ''生成4位数字的安全码
session("random_num")=random_num '为么调用session,没有session的安全码是完全没有意义的。呵呵 .
Set Jpeg = Server.CreateObject("Persits.Jpeg") '调用组件
Jpeg.Open Server.MapPath("t.jpg") '打开准备的图片
Jpeg.Canvas.Font.Color = &HFFFFFF
Jpeg.Canvas.Font.Family = "Arial Black"
Jpeg.Canvas.Font.Bold = false
Jpeg.Canvas.PrintText 0, -2, random_num
jpeg.save Server.MapPath("tt.jpg") '保存
%>
<img src="tt.jpg" border="0" align="absmiddle">
12、如何让AspJpeg组件支援数据库?
图片存进数据库只能以二进制数据保存,这里即利用AspJpeg的Binary方法,下面以两个AspJpeg用户手册上的代码为例,具体请参考AspJpeg用户手册:
Opening Images from Memory
<% ' Using ADO, open database with an image blob
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb")
Set rs = Server.CreateObject("adodb.recordset")
SQL = "select image_blob from images2 where id = " & Request("id")
内容版权声明:除非注明,否则皆为本站原创文章。