﻿// JScript 文件

var flag=false;
function DrawImage(ImgD,toWidth,toHeight)
{
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
    {
        flag=true;
        if(image.width/image.height>= toWidth/toHeight)
        {
            if(image.width>toWidth)
            {
                ImgD.width=toWidth;
                ImgD.height=(image.height*toWidth)/image.width;
            }
            else
            {
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            //ImgD.alt=ImgD.width+"×"+ImgD.height;
        }
        else
        {
            if(image.height>toHeight)
            {
                ImgD.height=toHeight;
                ImgD.width=(image.width*toHeight)/image.height;
            }
            else
            {
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            //ImgD.alt=ImgD.width+"×"+ImgD.height;
        }
    }
}
