﻿function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    if(image.width/image.height>= iwidth/iheight){
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }
    else{
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;
        }
    }
}

function fiximgwin(url)
{
var imgwin=window.open('','img','width=50,height=50,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=yes')
imgwin.focus()
var HTML="<html>\r\n<head>\r\n<title>imgview</title>\r\n</head>\r\n<body leftmargin=\"0\" topmargin=\"0\">\r\n<img src=\""+url+"\" onload=\"var w=this.width,h=this.height;if(w>800){h=h*800/w;w=800}if(h>600){w=w*600/h;h=600}window.resizeTo(w+10,h+56);window.moveTo((screen.width-w)/2,(screen.height-h)/2);this.height=h;this.width=w;\">\r\n</body>\r\n</html>"
var doc=imgwin.document
doc.open("text/html","replace")
doc.write(HTML)
doc.close()
}


