画布'drawImage'返回'找不到与提供的签名匹配的功能。' [英] Canvas 'drawImage' returns ' No function was found that matched the signature provided.'
问题描述
我有两张HTML5画布。我首先画一个临时的,然后我想把temp复制到最后一个。
除了drawImage函数之外,一切似乎都有效,因为它接受了图像以及画布。我已经尝试转换为DatatoUrl()方法但没有成功。
I have two HTML5 canvases. I draw first on a temp one and then I want to copy the temp to the final one. Everything seems to work except the drawImage function which is weird because it accepts Images as well Canvases. I tried already the convert to DatatoUrl() method with no success.
这些是我正在使用的对象。尺寸等都是稍后设定的。
These are the objects I am using. Sizes etc are all set later.
var paint = $('<canvas/>');
var temp_paint = $('<canvas/>');
temp_ctx = temp_paint[0].getContext('2d');
ctx = paint[0].getContext('2d');
任何想法?
这是代码
function paintMouseUp(e)
{
e.preventDefault();
draw=false;
ctx.drawImage(temp_paint, 0, 0);
temp_ctx.clearRect(0, 0, settings.width, settings.height);
mousePoints = [];
}
这是我得到的错误:
无法在'CanvasRenderingContext2D'上执行'drawImage':找不到与提供的签名匹配的函数。
推荐答案
temp_paint
是jQuery的对象,所以它可以不是 .drawImage()
第一个参数。您可以改为使用此代码:
temp_paint
is jQuery's object, so it can't be .drawImage()
first argument. You can use this code instead:
ctx.drawImage(temp_ctx.canvas, 0, 0);
这篇关于画布'drawImage'返回'找不到与提供的签名匹配的功能。'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!