提交 404139f5 编写于 作者: d-u-a's avatar d-u-a

update: H5 高清canvas canvasToTempFilePath模糊问题.

上级 d04fabd4
import createCallbacks from 'uni-helpers/callbacks'
import { wrapper } from 'uni-helpers/hidpi'
const canvasEventCallbacks = createCallbacks('canvasEvent')
......@@ -257,6 +258,7 @@ var tempCanvas
function getTempCanvas () {
if (!tempCanvas) {
tempCanvas = document.createElement('canvas')
wrapper(tempCanvas)
}
return tempCanvas
}
......@@ -816,7 +818,7 @@ export function canvasToTempFilePath ({
pageId = app.$route.params.__id__
} else {
invoke(callbackId, {
errMsg: 'canvasPutImageData:fail'
errMsg: 'canvasToTempFilePath:fail'
})
return
}
......@@ -840,20 +842,24 @@ export function canvasToTempFilePath ({
canvas.width = data.width
canvas.height = data.height
var c2d = canvas.getContext('2d')
c2d.putImageData(imgData, 0, 0)
var base64 = canvas.toDataURL('image/png')
var img = new Image()
img.onload = function () {
canvas.width = destWidth || imgData.width
canvas.height = destHeight || imgData.height
c2d.drawImage(img, 0, 0)
base64 = canvas.toDataURL(`image/${fileType.toLowerCase()}`, qualit)
c2d.putImageData(imgData, 0, 0, 0, 0, destWidth || imgData.width, destHeight || imgData.height)
var base64 = canvas.toDataURL(`image/${fileType.toLowerCase()}`, qualit)
invoke(callbackId, {
errMsg: 'canvasToTempFilePath:ok',
tempFilePath: base64
})
}
img.src = base64
// var img = new Image()
// img.onload = function () {
// canvas.width = destWidth || imgData.width
// canvas.height = destHeight || imgData.height
// c2d.drawImage(img, 0, 0)
// base64 = canvas.toDataURL(`image/${fileType.toLowerCase()}`, qualit)
// invoke(callbackId, {
// errMsg: 'canvasToTempFilePath:ok',
// tempFilePath: base64
// })
// }
// img.src = base64
})
operateCanvas(canvasId, pageId, 'getImageData', {
x,
......
......@@ -19,7 +19,7 @@ import {
import {
wrapper
} from './hidpi'
} from 'uni-helpers/hidpi'
function resolveColor (color) {
color = color.slice(0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册