提交 62bd1f92 编写于 作者: Q qiang

fix: 解决 PC 浏览器 uni.canvasToTempFilePath 报错的问题

上级 48475beb
......@@ -36,9 +36,9 @@ const ratioArgs = {
'createLinearGradient': 'all',
'setTransform': [4, 5]
}
if (pixelRatio !== 1) {
const proto = CanvasRenderingContext2D.prototype
const proto = CanvasRenderingContext2D.prototype
if (pixelRatio !== 1) {
forEach(ratioArgs, function (value, key) {
proto[key] = (function (_super) {
return function () {
......@@ -129,23 +129,6 @@ if (pixelRatio !== 1) {
}
})(proto.strokeText)
proto.drawImageByCanvas = (function (_super) {
return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
srcx *= pixelRatio
srcy *= pixelRatio
srcw *= pixelRatio
srch *= pixelRatio
desx *= pixelRatio
desy *= pixelRatio
desw = isScale ? desw * pixelRatio : desw
desh = isScale ? desh * pixelRatio : desh
_super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh)
}
})(proto.drawImage)
proto.drawImage = (function (_super) {
return function () {
if (!this.__hidpi__) {
......@@ -158,6 +141,23 @@ if (pixelRatio !== 1) {
})(proto.drawImage)
}
proto.drawImageByCanvas = (function (_super) {
return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
srcx *= pixelRatio
srcy *= pixelRatio
srcw *= pixelRatio
srch *= pixelRatio
desx *= pixelRatio
desy *= pixelRatio
desw = isScale ? desw * pixelRatio : desw
desh = isScale ? desh * pixelRatio : desh
_super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh)
}
})(proto.drawImage)
export function wrapper (canvas) {
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册