小编Sti*_*cky的帖子

第一次使用另一个画布作为源参数时,画布绘制图像速度较慢

第一次使用另一个画布作为绘图源时,我看到画布绘制速度很慢。随后的 canvas 到 canvas .drawImage 调用都很好,直到我交换图像(然后我再次看到相同的问题)。

下面的示例代码 - 加载图像,然后创建 4 个画布,第一个画布从图像本身绘制,第二个画布从第一个画布绘制,依此类推。创建画布后,交换源图像并运行代码再次。

        var sourceImage = new Image();  // Original image
        var myImages = []; // Array of image and canvases references
        myImages[0] = sourceImage; // Set first myImage to image source

        // Image onload 
        sourceImage.onload = function () {
     
            console.log("Imageload", new Date() - t0);
            myImages[0] = sourceImage;

            // Loop to create and draw on canvases
            for (var i = 1; i <= 4; i += 1) {

                // Create canvas
                myImages[i] …
Run Code Online (Sandbox Code Playgroud)

javascript canvas image drawimage

5
推荐指数
1
解决办法
1439
查看次数

标签 统计

canvas ×1

drawimage ×1

image ×1

javascript ×1