js同比例缩放图片
2013-09-03 15:14
288 查看
function DrawImage(ImgD, FitWidth, FitHeight) { var image = new Image(); image.src = ImgD.src; if (image.width > 0 && image.height > 0) { if (image.width / image.height >= FitWidth / FitHeight) { if (image.width > FitWidth) { ImgD.width = FitWidth; ImgD.height = (image.height * FitWidth) / image.width; } else { ImgD.width = image.width; ImgD.height = image.height; } } else { if (image.height > FitHeight) { ImgD.height = FitHeight; ImgD.width = (image.width * FitHeight) / image.height; } else { ImgD.width = image.width; ImgD.height = image.height; } } } }
相关文章推荐
- [JS]JS控制图片超过宽度自动缩小图片等比例缩放源代码实例
- JS控制图片显示的大小(图片等比例缩放)
- js实现图片的等比例缩放
- js将图片按比例缩放显示IE6
- 按比例缩放图片的js代码
- JS控制图片显示的大小(图片等比例缩放)
- js等比例缩放图片
- js+jQuery按比例缩放图片(网络图片或本站图片均适用)
- 等比例缩放图片 js
- js等比例缩放图片
- 图片预加载并且自动等比例缩放的JS插件[转]
- JS控制图片等比例缩放
- JS控制图片显示的大小(图片等比例缩放)
- JS控制图片显示的大小(图片等比例缩放)
- js控制图片按比例缩放
- JS控制图片显示的大小(图片等比例缩放)
- 【js与jquery】js控制图片显示大小(图片等比例缩放)
- JS控制图片显示的大小(图片等比例缩放)
- 【JS控制图片显示的大小(图片等比例缩放)】
- JS实现按比例缩放图片的方法(附C#版代码)