/*
***函数名 : DrawImage
***函数说明: 图片等比例缩放
***参数 :
obj: 当前img控件
iFitWidth: 合适的宽度
iFitHeight: 合适的高度
***返回值 : Null
*/
function DrawImage(obj, iFitWidth, iFitHeight) {
var image = new Image();
image.src = obj.src;
if (image.width>0 && image.height>0) {
if (image.width/image.height >= iFitWidth/iFitHeight) {
if (image.width > iFitWidth) {
obj.width = iFitWidth;
obj.height = (image.height*iFitWidth)/image.width;
}
else {
obj.width = image.width;
obj.height = image.height;
}
}
else {
if (image.height>iFitHeight) {
obj.width = (image.width*iFitHeight)/image.height;
obj.height = iFitHeight;
}
else {
obj.width = image.width;
obj.height = image.height;
}
}
}
}