﻿function DrawImage(ImgD,WidthNum,HeightNum){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width/image.height>= WidthNum/WidthNum){ 
if(image.width>WidthNum){ 
ImgD.width=WidthNum; 
ImgD.height=(image.height*WidthNum)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 

} 
else{ 
if(image.height>HeightNum){ 
ImgD.height=HeightNum; 
ImgD.width=(image.width*HeightNum)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 

} 
} 
} 

function  RatImg(Img,blw,blh) 
{ 
var   i=Img.width; 
var   j=Img.height;   

if   (i> blw) 
{ 
    var   zjbl1=blw/i; 
    var   zjbl2=blh/j; 
    if   (zjbl1 <zjbl2) 
    { 
        zjbl=zjbl1; 
    } 
    else 
    { 
        zjbl=zjbl2; 
    } 
    i=i*zjbl; 
    j=j*zjbl; 
} 
else 
{ 
    if   (j> blh) 
    { 
        zjbl=blh/j; 
        j=blh; 
        i=i*zjbl; 
    } 
} 

Img.width=i; 
Img.height=j; 
} 

