fix: canvas2d 在ios 侧渲染问题

This commit is contained in:
CPPAlien 2021-03-22 17:01:47 +08:00
parent 1d0d056e9b
commit 4f7456f0f3

View File

@ -689,9 +689,7 @@ Component({
this.canvasHeightInPx = height.toPx(); this.canvasHeightInPx = height.toPx();
needScale = needScale || this.properties.use2D; needScale = needScale || this.properties.use2D;
} }
this.setData({
photoStyle: `width:${this.canvasWidthInPx}px;height:${this.canvasHeightInPx}px;`,
});
if (!this.photoContext) { if (!this.photoContext) {
this.photoContext = await this.getCanvasContext(this.properties.use2D, 'photo'); this.photoContext = await this.getCanvasContext(this.properties.use2D, 'photo');
} }
@ -701,10 +699,15 @@ Component({
this.photoContext.height = this.canvasHeightInPx * scale; this.photoContext.height = this.canvasHeightInPx * scale;
this.photoContext.scale(scale, scale); this.photoContext.scale(scale, scale);
} }
new Pen(this.photoContext, palette).paint(() => {
this.saveImgToLocal(); this.setData({
photoStyle: `width:${this.canvasWidthInPx}px;height:${this.canvasHeightInPx}px;`,
}, () => {
new Pen(this.photoContext, palette).paint(() => {
this.saveImgToLocal();
});
setStringPrototype(this.screenK, this.properties.scaleRatio);
}); });
setStringPrototype(this.screenK, this.properties.scaleRatio);
}); });
}, },
@ -776,8 +779,8 @@ Component({
wx.canvasToTempFilePath({ wx.canvasToTempFilePath({
canvasId: 'photo', canvasId: 'photo',
canvas: that.properties.use2D ? that.canvasNode : null, canvas: that.properties.use2D ? that.canvasNode : null,
destWidth: that.canvasWidthInPx * getApp().systemInfo.pixelRatio, destWidth: that.canvasWidthInPx,
destHeight: that.canvasHeightInPx * getApp().systemInfo.pixelRatio, destHeight: that.canvasHeightInPx,
success: function (res) { success: function (res) {
that.getImageInfo(res.tempFilePath); that.getImageInfo(res.tempFilePath);
}, },