キャンバスのサイズは、画面サイズに合わせてスケーリングされたキャンバスにCSSを使って、(1200 * 800)に設定されています。
これは、シミュレータの開発ツールでは問題ありませんが、本当のテスト変換やズームを使用しているかどうか、無効であるときです。
携帯電話のスクリーン装置の画素比率が今や2つよりも一般的であるため、本質的に、大きな画像を生成します。実際には、我々はwx.canvasToTempFilePathを使用して提供してdestWidth destHeight(出力の幅と高さ)をパラメータされている場合にのみ必要と缶の2倍以上の幅と高さです。
context.draw(true, setTimeout(function() {
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 670,
height: 959,
destWidth: 2010,
destHeight: 2877,
canvasId: 'mycanvas',
success: function(res) {
var tempFilePath = res.tempFilePath;
that.setData({
imagePath: tempFilePath,
canvasHidden: true
});
},
fail: function(res) {
console.log(res);
}
});
}, 200));