发现有教程,可是运行不起来,看你会吗?
picclass.asp 图片处理类文件
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<%
'//////////// GPS:Get Picture Size //////////////
'//////////////利用ADODB.stream获取图片尺寸//////////////
'/////////Cited By Leon(心晴) 2005年8月11日//////////
Class GPS
Dim aso
Private Sub Class_Initialize
Set aso=CreateObject("Adodb.Stream")
aso.Mode=3
aso.Type=1
aso.Open
End Sub
Private Sub Class_Terminate
set aso=nothing
End Sub
Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if AscB(clow)<128 then
Str = Str &Chr(ASCB(clow))
Else
I=I+1
if I <= LenB(Bin) then Str = Str &Chr(ASCW(MidB(Bin,I,1)&clow))
end If
Next
Bin2Str = Str
End Function
Private Function Num2Str(num,base,lens)
'GPS (2005-8-11)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) &ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") &num &ret,lens)
End Function
Private Function Str2Num(str,base)
'GPS (2005-8-11)
dim ret
ret = 0
for i=1 to len(str)
ret = ret *base + cint(mid(str,i,1))
next
Str2Num=ret
End Function
Private Function BinVal(bin)
'GPS (2002-8-11)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function
Private Function BinVal2(bin)
'GPS (2002-8-11)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function
'///以下是调用代码///
Function getImageSize(filespec)
'GPS (2002-8-11)
dim ret(3)
aso.LoadFromFile(filespec)
bFlag=aso.read(3)
select case hex(binVal(bFlag))
case "4E5089":
aso.read(15)
ret(0)="PNG"
ret(1)=BinVal2(aso.read(2))
aso.read(2)
ret(2)=BinVal2(aso.read(2))
case "464947":
aso.read(3)
ret(0)="GIF"
ret(1)=BinVal(aso.read(2))
ret(2)=BinVal(aso.read(2))
case "535746":
aso.read(5)
binData=aso.Read(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
while(len(sConv)<nBits*4)
binData=aso.Read(1)
sConv=sConv&Num2Str(ascb(binData),2 ,8)
wend
ret(0)="SWF"
ret(1)=int(abs(Str2Num(mid(sConv,1*nBits+1,nBits),2)-Str2Num(mid(sConv,0*nBits+1,nBits),2))/20)
ret(2)=int(abs(Str2Num(mid(sConv,3*nBits+1,nBits),2)-Str2Num(mid(sConv,2*nBits+1,nBits),2))/20)
case "FFD8FF":
do
do: p1=binVal(aso.Read(1)): loop while p1=255 and not aso.EOS
if p1>191 and p1<196 then exit do else aso.read(binval2(aso.Read(2))-2)
do:p1=binVal(aso.Read(1)):loop while p1<255 and not aso.EOS
loop while true
aso.Read(3)
ret(0)="JPG"
ret(2)=binval2(aso.Read(2))
ret(1)=binval2(aso.Read(2))
case else:
if left(Bin2Str(bFlag),2)="BM" then
aso.Read(15)
ret(0)="BMP"
ret(1)=binval(aso.Read(4))
ret(2)=binval(aso.Read(4))
else
ret(0)=""
end if
end select
ret(3)="width=""" &ret(1) &""" height=""" &ret(2) &""""
getimagesize=ret
End Function
End Class
%>
图片调用文件----------------------------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="picclass.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function maxview(){
if (window.screen){
var w=screen.availwidth
var h=screen.availheight
window.moveTo(0,0)
window.resizeTo(w,h)
}
}
// -->
</SCRIPT>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title></title>
<SCRIPT src="zoom.js" type=text/javascript></SCRIPT>
</head>
<body onLoad="maxview()OnLoadMainFunction()">
<table width="905" border="0" align="center" cellpadding="15" cellspacing="1">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="15"
cellpadding="0">
<tr>
<td valign="top">
<%
if request("showid")<>"" then
sql="update lei_product set dianjishu=dianjishu+1 where id="&(request("showid"))
conn.execute(sql)
set rs=server.CreateObject("adodb.recordset")
showstr="select * from lei_product where id="&(request("showid"))
rs.open showstr,conn,1,1
if not rs.bof and not rs.eof then
'/////获取ShowImg.asp的绝对路径/////
Dim curFile
curFile=Server.mappath(Request.servervariables("PATH_INFO"))
Dim curfilename,filename
'/////图片相对路径(存于数据库中)
'cufilename=rs("ImgURL")
cufilename="../admin/upimg/"&rs("bigimg2")
cufilename2="../admin/upimg/"&rs("bigimg")
'/////因为ShowImg.asp与images在同一目录,所以我们用instrrev获取images的路径/////
filename=left(curFile,instrrev(curFile,"\"))&cufilename
filename2=left(curFile,instrrev(curFile,"\"))&cufilename2
'/////建立GPS类实体/////
Dim GetPicSize
Set GetPicSize=new GPS
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'/////获取图片类型/////
Dim PicSuffixName
Dim PicSuffixName2
if (fs.FileExists(filename)=false) then
Response.Write("<script>alert('文件加载失败,请确认文件是否存在')history.back(-1)</script>")
Response.End()
end if
if (fs.FileExists(filename2)=false) then
Response.Write("<script>alert('文件加载失败,请确认文件是否存在')history.back(-1)</script>")
Response.End()
end if
PicSuffixName=fs.GetExtensionName(filename)
PicSuffixName2=fs.GetExtensionName(filename2)
Dim PD '//Picture Dimension
Dim PD2 '//Picture Dimension
Dim PWidth,PHeight
Dim PWidth2,PHeight2
PD=GetPicSize.GetImageSize(filename)
PD2=GetPicSize.GetImageSize(filename2)
PWidth=PD(1) '//获取图片宽度
PWidth2=PD2(1) '//获取图片宽度
PHeight=PD(2) '//获取图片高度
PHeight2=PD2(2) '//获取图片高度
Set fs=Nothing
Set GetPicSize=Nothing
%>
<SCRIPT type=text/javascript>
var usezoom = 1
var itemimagedir = ''
var zoom_bigimagediv = 'bigimagediv'
var zoom_bigimagetablediv = 'bigimagetablediv'
var zoom_highlightdiv = 'highlightdiv'
var zoom_bigimageouterdiv = 'bigimageouterdiv'
var zoom_viewportwid = 400//大图图片显示区域
var zoom_viewporthei = 320//大图片显示区域
var zoom_mainimagewid = <%=PWidth2%>//小图宽
var zoom_mainimagehei = <%=PHeight2%>//小图高
var zoom_mainimageurl = '../admin/upimg/<%=rs("bigimg2")%>'
var zoom_zoomimagewid = <%=PWidth%>//原图大小宽
var zoom_zoomimagehei = <%=PHeight%>//原图大小高
var zoom_zoomimageurl = '../admin/upimg/<%=rs("bigimg2")%>'//大图地址
var zoom_bigimagetablexoffset = 1
var zoom_bigimagetableyoffset = 21
var zoom_displayxposition = 0
var zoom_displayyposition = 0
var zoom_miniimagex = 0
var zoom_miniimagey = 0
var zoom_highlightbgcolor = 'ffffff'
var zoom_highlightimage = 'highlight.gif'
function GetZoomObjectData() {
var position
if (!InIE &&!InNS6 &&!DOMCompatible)
return
position = MeMSOObjectGetPosition('mainimage')
zoom_miniimagex = position.x
zoom_miniimagey = position.y
position = MeMSOObjectGetPosition('locatezoomim')
zoom_displayxposition = position.x//显示图片的位置
zoom_displayyposition = position.y - 21
Zoom_StartupZoomRegion()
}
onloadlist += 'GetZoomObjectData()'
</SCRIPT>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td bgcolor="#FFFFFF"><div align="center">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td valign="center" align="middle" rowspan="4"><table cellspacing="1"
cellpadding="2" width="<%=PWidth2%>"
bgcolor="#efe6dd" border="0" height="<%=PHeight2%>">
<tbody>
<tr>
<td bgcolor="#ffffff"><img
src="..\admin\upimg\<%=rs("bigimg")%>" name="mainimage"
border="0" width="<%=PWidth2%>" height="<%=PHeight2%>"
id="mainimage" /></td>
</tr>
</tbody>
</table>
<br />
<a href="#" target="_blank">点击看大图</a></td>
<td valign="bottom" align="left" height="5"><img height="5"
src="dot_line.gif" width="401" /></td>
</tr>
<tr>
<td valign="bottom" align="left" width="420" height="1"><table cellspacing="0"
cellpadding="0" width="100%"
border="0">
<tbody>
<tr>
<td colspan="2"><img id="locatezoomim" height="1"
src="dot_1.gif" width="1"
name="locatezoomim" /></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td valign="top" align="left" width="425"
background="bigImg.gif"
height="330"><p> </p></td>
</tr>
<tr>
<td align="middle"><div id="highlightdiv"
style="Z-INDEX: 2LEFT: -2000pxPOSITION: absoluteTOP: -2000px
visibility: hidden"></div>
<div id="bigimageouterdiv"
style="Z-INDEX: 4LEFT: -2000pxVISIBILITY: visibleOVERFLOW:
hiddenWIDTH: 300pxPOSITION: absoluteTOP: -2000pxHEIGHT: 300px">
<div id="bigimagediv"
style="Z-INDEX: 4LEFT: -2000pxPOSITION: absoluteTOP: -2000px
visibility: hidden"><img
id="mainzoomimage" height="2400" src="" width="800" border="0"
name="mainzoomimage" /></div>
</div>
<div id="bigimagetablediv" style="Z-INDEX: 3LEFT: -2000pxPOSITION:
absoluteTOP: -2000pxvisibility: hidden"></div></td>
</tr>
</tbody>
</table>
</div>
<div align="right"></div></td>
</tr>
</table>
<%end if
rs.close
set rs = nothing
%>
<%end if
%>
</td>
</tr>
</table></td>
</tr>
</table>
<table width="905" height="8" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
</body>
</html>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script><!--引入jquery库--><style>
* {margin:0padding:0}
.parentCls {margin:0position:relative}
.inputElem {height:24px border:1px solid #ddd outline:none }
#fixval {position:absolute top:-35px left:0 display:none border:1px solid #ddd background:#fff font-size:18px font-weight:bold color:#F60 padding:5px }
</style>
<div style="height:50px"></div>
<div class="parentCls">
<input type="text" class="inputElem" autocomplete = "off" maxlength="18"/>
<div id="fixval"></div>
</div>
<script>
$(function(){
$(".inputElem").keyup(function(event){
var txt = $(this).val()
var keyCode = event.which
if ( txt.length<=0 ) {
$("#fixval").hide()
}else{
if ( $.isNumeric(txt) !== true || keyCode==32 ){//判断输入类型,并去除空格
$(this).val( txt.slice(0,-1) ) //截掉非数字和空格
return false
}
var re=/(?=(?!\b)(\d{3})+$)/g //分割数字 1,000
txt = txt.replace(re,",")
$("#fixval").html(txt).show()
}
})
})
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8"/>
<title>放大镜</title>
<meta name="keywords" content="" />
<meta name="Description" content="" />
<style type="text/css">
body,div,img {padding:0margin:0}
.con {width:256pxheight:192pxfloat:left}
.con img {width:256pxheight:192pxposition:absoluteborder:1px blue solid}
.dingwei {position:absolutewidth:100pxheight:100pxbackground-color:blackfilter:alpha(opacity=20)opacity:0.2cursor:movedisplay:none}
.big {float:leftwidth:400pxheight:400pxmargin:100pxoverflow:hidden}
</style>
</head>
<body>
<div class="con" id="father" style="position:relative">
<img src="images/huo.jpg" alt="图片"/>
<div id="aa" class="dingwei"> </div>
</div>
<div class="big" id="bpic">
<div class="inside"><img src="images/huo.jpg" alt="图片"/></div>
</div>
<script type="text/javascript">
var divs=document.getElementById("aa")
var fa=document.getElementById("father")
var maxWidth=maxHeight=S=0
var big=document.getElementById("bpic")
fa.onmouseover=function(){
divs.style.display="block"
big.style.display="block"
S=divs.offsetHeight/2
maxWidth=fa.clientWidth-divs.offsetWidth
maxHeight=fa.clientHeight-divs.offsetHeight//物块的活动范围;
}
fa.onmousemove=function(e){
a=e||window.event
var sbX=a.clientX
var sbY=a.clientY
var num=big.clientWidth/divs.clientWidth
var lf=sbX-S//鼠标的位置减去元素位置的一半的值就是元素的定位值;
var tp=sbY-S
//tp =tp<0?0:tp>maxHeight?maxHeight:tp
//lf =lf<0?0:lf>maxWidth?maxWidth:lf//判断物块的定位位置然后进行设置
if(tp<0){tp=0}
else{
if(tp>maxHeight){tp=maxHeight}
else{tp=sbY-S}
}
//判断物块的位置进行设置
if(lf<0){lf=0}
else{
if(lf>maxWidth){lf=maxWidth}
else{lf=sbX-S}
}
divs.style.left=lf+"px"
divs.style.top=tp+"px"
big.scrollLeft=num*lf
big.scrollTop=num*tp
}
fa.onmouseout=function(){
divs.style.display="none"
big.style.display="none"
}
</script>
</body>
</html>
这是放大镜效果的代码 你说的开启和关闭你自己再加上去就行了