﻿// JScript 文件
/*
处理图片的大小设置
maxwidth//定义允许图片宽度 
minheight //定义允许图片高度 
*/
 function DrawImage(ImgD,maxwidth,minheight) {
    var image = new Image();
    if(maxwidth==null||maxwidth=='undefined')
     maxwidth=135;
    if(minheight ==null||minheight=='undefined')
     minheight=118  
    image.src = ImgD.src;
        if (image.width > 0 && image.height > 0) {
            flag = true;
            if (image.width / image.height >= maxwidth / minheight) {
                if (image.width > maxwidth) {
                    ImgD.width = maxwidth;
                    ImgD.height = (image.height * maxwidth) / image.width;
                } else {
                    ImgD.width = image.width;
                    ImgD.height = image.height;
                }
              
            }
            else {
                if (image.height > minheight) {
                    ImgD.height = minheight;
                    ImgD.width = (image.width * minheight) / image.height;
                } else {
                    ImgD.width = image.width;
                    ImgD.height = image.height;
                }
               
            }
        }
    }