按比例显示图片,读OLE对象图片的方法

王朝网络·asp·作者佚名  2006-01-09
宽屏版  字体: |||超大  

<!--#include file="conn.asp"-->

<% width=272:height=229 %>

<% set rs=server.CreateObject("adodb.recordset")

sql="select * from imgbook where id=223 order by id desc"

rs.open sql,conn,1,1

%>

<% w=rs("width"):h=rs("height")

m=w/width:n=h/height

if w>=width or h>=height then

if m>n then

w1=width:h1=h/m

elseif m<n then

h1=height:w1=w/n

else

w1=width:h1=height

end if

else

w1=w:h1=h

end if %>

<a href="product_s.asp?id=<%=rs("ID")%>&title=<%=rs("title")%>">

<img src="showimg.asp?id=<%=rs("id")%>" width=<%=w1%> height=<%=h1%> border="0"></a>

+++++++++++++++showimg.asp++++++++++++++++++++++

<!--#include file="conn.asp"-->

<%

id=clng(trim(request("id")))

/.Trim(string) 返回 String,去除字符串开头及结尾的空格。

CLng(expression) 返回表达式,此表达式已被转换为 Long 子类型的 Variant。. /

if id="" then response.End

response.Expires=0

response.buffer=true

response.Clear()

set rs=server.CreateObject("adodb.recordset")

sql="select * from imgbook where ID="&id&""

rs.open sql,conn,3,1

response.ContentType="image/*"

response.BinaryWrite rs("photo")

rs.close

set rs=nothing

conn.close

set conn=nothing

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有