首页 热点专区 义务教育 高等教育 出国留学 考研考公

★■●程序如何控制 图片小于等于350px 怎么做.

发布网友

我来回答

1个回答

热心网友

给你例子可以参考

思路:先获取图片长度和宽度,再定义一个最大的显示长度和宽度,当图片的长度或宽度大于最大长度或宽度时,等比例缩小图片尺寸.

function getW(imgpath) '获得最终显示的图片宽度的函数

set pp=new imgInfo
w = pp.imgW(server.mappath(imgpath)) 'imgpath就是通过ASP从数据库中获得的图片路径
h = pp.imgH(server.mappath(imgpath))
wtoh=w/h '获得图片原尺寸的长宽比

dim ww,hh
if w>=150 and h>=150 then '这里定义一个最大长和宽 150
if w>=h then
ww=150
hh=ww/wtoh
getW=ww
else
hh=150
ww=hh*wtoh
getW=ww
end if
else
ww=w
hh=h
getW=ww
end if
set pp=nothing
end function

function getH(imgpath) '获得最终显示的图片长度的函数

set pp=new imgInfo
w = pp.imgW(server.mappath(imgpath))
h = pp.imgH(server.mappath(imgpath))
wtoh=w/h

dim ww,hh
if w>=150 and h>=150 then
if w>=h then
ww=150
hh=ww/wtoh
getH=hh
else
hh=150
ww=hh*wtoh
getH=hh
end if
else
ww=w
hh=h
getH=hh
end if
set pp=nothing
end function

function getP(imgpath) '获得图片路径的函数
getP=imgpath
end function

response.write "<img src='"&getP("图片路径可以由ASP动态生成")&"' border=0 width='"&getW("图片路径可以由ASP动态生成")&"' heidth='"&getH("图片路径可以由ASP动态生成")&"'>"

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com