图片处理的问题呀
<%
Function BinVal2(bin)
Dim i
Dim ret:ret = 0
for i = 1 to lenb(bin)
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal2 = ret
End Function
Function BinVal(bin)
Dim i
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
function SetImage(IMGPath,width,height,MAX)
dim W,H,style,ret(2),bFlag,ADOS
'On Error Resume Next
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get","http://www.cnznc.com/"&IMGPath, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
Set ADOS = Server.CreateObject("ADODB.Stream")
ADOS.Type = 1
ADOS.Mode = 3
ADOS.Open
ADOS.Write GetBody
ADOS.Position = 0
bFlag = ADOS.read(3)
if isNull(bFlag) then
ret(0) = "unknow"
ret(1) = 0
ret(2) = 0
Exit Function
end if
'取文件类型和长宽
select case hex(binVal(bFlag))
case "464947":
ADOS.read(3)
ret(0) = "gif"
ret(1) = BinVal(ADOS.read(2))
ret(2) = BinVal(ADOS.read(2))
case "FFD8FF":
dim p1
do
do: p1 = binVal(ADOS.Read(1)): loop while p1 = 255 and not ADOS.EOS
if p1 > 191 and p1 < 196 then exit do else ADOS.read(binval2(ADOS.Read(2))-2)
do:p1 = binVal(ADOS.Read(1)):loop while p1 < 255 and not ADOS.EOS
loop while true
ADOS.Read(3)
ret(0) = "jpg"
ret(2) = binval2(ADOS.Read(2))
ret(1) = binval2(ADOS.Read(2))
ADOS.Close
Set ADOS = Nothing
end select
W=ret(1)
H = ret(2)
if H>W then
if W>MAX then
style=" style='margin-left:-" & cint(MAX-width)/2 & "px;margin-top:-" & cint((cint(MAX-width)*H)/W)/2 & "px'"
SetImage=style&" width=" & MAX' & " alt='" & W & "," & H & "'"
'else
'style=" style='margin-left:-" & cint(W-width)/2 & "px;margin-top:-" & cint((cint(W-width)*H)/W) & "px'"
end if
else
if H>MAX then
style=" style='margin-left:-" & cint((cint(MAX-height)*W)/H)/2 & "px;margin-top:-" & cint(MAX-height)/2 & "px'"
SetImage=style&" height=" & MAX' & " alt='" & W & "," & H & "'"
else
'style=" style='margin-left:-20px;margin-top:-20px'"
SetImage=style&" onload='if(this.height>this.width){if(this.width>"&width&")this.width="&width&";}else{if(this.height>" & height & "){this.height=" & height & ";}else{this.width=" & width & ";this.height=" & height & ";}}'"
end if
end if
end function
%>
为什么这段代码只能显示图片的一个左上角呀。。请高手回答呀。。急~~~~
问题点数:0、回复次数:0Top




