﻿function DrawImage(ImgD,width,height){
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        if(image.width/image.height>= width/height){
            if(image.width>width){
                ImgD.width=width;
                ImgD.height=(image.height*width)/image.width;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
        else{
            if(image.height>height){
                ImgD.height=height;
                ImgD.width=(image.width*height)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
    }
}
function fiximgwin(url)
{
    var imgwin = window.open('', 'img', 'width=50,height=50');
    imgwin.focus();
    var HTML = "<html>\r\n<head>\r\n<title>图片浏览</title>\r\n</head>\r\n<body leftmargin=\"0\" topmargin=\"0\">\r\n<img src=\"" + url + "\" onload=\"window.resizeTo(this.width+10,this.height+50);window.moveTo((screen.width-this.width)/2,(screen.height-this.height)/2)\">\r\n</body>\r\n</html>";
    var doc = imgwin.document;
    doc.open("text/html", "replace");
    doc.write(HTML);
    doc.close();
}