- //自动缩放图片大小
- var flag=false;
- function DrawImage(ImgD,wid,hei)
- {
- var image=new Image();
- image.src=ImgD.src;
- if(image.width>0 && image.height>0)
- {
- flag=true;
- if(image.width/image.height>= wid/hei)
- {
- if(image.width>wid)
- {
- ImgD.width=wid;
- ImgD.height=(image.height*hei)/image.width;
- }
- else
- {
- ImgD.width=image.width;
- ImgD.height=image.height;
- }
- /*ImgD.alt="bigpic" */
- }
- else
- {
- if(image.height>hei)
- {
- ImgD.height=hei;
- ImgD.width=(image.width*hei)/image.height;
- }
- else
- {
- ImgD.width=image.width;
- ImgD.height=image.height;
- }
- /*ImgD.alt="bigpic" */
- }
- }
- }