Canvas drawImage scaling

后端 未结 3 889
误落风尘
误落风尘 2020-12-24 00:38

I\'m trying to scale an image proportionately to the canvas. I\'m able to scale it with fixed width and height as so:

context.drawImage(imageObj, 0, 0, 100,          


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 01:19

    context.drawImage(imageObj, 0, 0, 100, 100 * imageObj.height / imageObj.width)
    

提交回复
热议问题