【问题标题】:How can you resize a new image object without cropping it?如何在不裁剪的情况下调整新图像对象的大小?
【发布时间】:2014-03-07 02:32:15
【问题描述】:

有没有办法在不裁剪的情况下加载更大或更小的图像?我不希望它看起来更小或更大。我希望它实际上更小或更大。我尝试将these parameters 用于新的 Image() 对象,还有吗?

_img = new Image(50, 50); //These parameters will crop it
_img.addEventListener('load',onImage,false);
_img.width = 50;//This will crop it.  

_img.style.width = "50px";//This doesn't change the original width to read `50`.  
console.log(_img.width);

【问题讨论】:

标签: javascript jquery image object


【解决方案1】:

即使您的问题不清楚,我认为您必须在加载后使用画布重新绘制它...这个答案可能会给您一个方向 Resizing a .png image when drawing to HTML5 canvas using JavaScript

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 2020-09-15
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    相关资源
    最近更新 更多