Canvas drawImage vs putImageData

JavaScript performance comparison

Revision 49 of this test case created by Chad

Info

Compare the tile drawing speed of ctx.drawImage against ctx.putImageData.

Each function pulls image data out of a source image / imageData object and writes to another canvas at varrying positions.

Note: As of 2014/03/28 ctx.drawImage() is roughly twice as fast in Chrome Version 29.0.1547.66

Preparation code

<canvas width=160 height=175 id="drawImageCanvas"></canvas>
<canvas width=160 height=175 id="putImageDataCanvas"></canvas>
<canvas width=160 height=175 id="tileImageCanvas"></canvas>
<img id="tileImage" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACwCAYAAACIGWW2AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gMcEDsh1XIZHgAAHPBJREFUeNrtXW2MHdV5fs71rEOLjVparCiKELH9Y38kVQgbadUNLcULwjay13ZpaFSpNSW7KNgkEg7cxFt36+6GhS5VwEFil8QkUtuQOPtRC3+A7UBUjDbKmlKJHxsJnNRSq8ioTmovjcKOOf0xc+aeOfecM2fmnJk79+680ujemXc+zzzzvB/zzjkEljK5DXTwwNlM25KePkxuA/jt93ynL7bON/7yrHQ9AJg62Kfd/9BRYHKbXk8XzhLS00eznD9dOEsAUDiUqYN9ZOio8nhUsr70uhT3KnX7OMCHdv+e7QEGD5zF1ME+pAUh6emLbc/kDxQNLK5n0oCG50Hn716TedukBk6jHzxwNvGm6x66pG2Z3rbNXErNxU5k4DABX5mk98WlXNYtStKwlQtmcyWeqx2ZMqFr8Jk+9UmShgX5dV0dvwjgybZr9fl5Lg+WlgmzXIxoPvj5tCbPxQ2wPb4LHyvrNZj4hDbtY7J/D20iDNh8g5TJl6mkhT5gETJ44CzoQnwqky/TDr5fGX1BYrsDMTVgkhoRtjfaRraeqwbMGgW7DkboQnImoYwBXCmCkFaJbRqk1cfn9SZpJtHnzPv8895/DZVUspJ9QNLTp33SVOa3ksoEO/V7mG+TNrItex4ub30rgxgX+3cKQBMHWZa3mjrY1wRE0yClk/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q6UAAFmFqszJYXszXUVFwmZ7OMrKFjRnN0/yWwRTb1hJ67Xrh7caAK6WtCo2CV4q4YsC8z7EV91D1FsX0TUnpouAygtsVA66EtqqCkAIYMAt4K2kjAJbthq2EKJiZUtPfigHbiAHLLnO7j2Dg+XtS/XZsGqaTo+C8z9EmlZIWhE7TMDYR1EoAr20UXEQ72dzDtOZ3bveRKMrtyCg47Q2TravbPqsZzQKmvH3AdieAtv8umJU1ua4ucXXcdgCIaeWKKGeWjpCWA7Bsr/HE87KtJ1TV86VlwBIDMfMD/KuX1N/DTE9PGz3AVRCSYwBSZNtmPU7RlkM8btU1R84+XDuUYplajrTWIymIm5mZqfKAaRhwJQYJeVuRCoAFMGDVhupEfgXAigErBqwYsGLASnJkwJUOwooBqyi4sxlQ9tWYzW8nM2Ant5UVA2a9cFmOx/a3Uxkw77YqK3gTGdDmwl03aNlA6JIB82grGyIoDQPaXngnmxRXDJi3Gba5h61kQC/rha8Ux9rFu+Aiv4rLcg/zrvLWlbOVrhqmU33AMvfmlaWbElcPt1U1TJ7ds3UiA7I+ZfLons0G2K18KP4fbUsU7z3Rk4wAAAAASUVORK5CYII=">
<script>
var drawImageCanvas = document.getElementById('drawImageCanvas');
var drawImageCTX = drawImageCanvas.getContext('2d');

var putImageDataCanvas = document.getElementById('putImageDataCanvas');
var putImageDataCTX = putImageDataCanvas.getContext('2d');

var tileImage = document.getElementById('tileImage');

var tileImageCanvas = document.getElementById('tileImageCanvas');
var tileImageCTX = tileImageCanvas.getContext('2d');

var tileWidth = 16;
var tileHeight = 16;
var tilesWide = 10;
var tilesHigh = 11;

tileImageCTX.drawImage(tileImage, 0, 0);

function drawImageTile(ctx, image, tilesWide, tilesHigh, tileWidth, tileHeight, tileNumber, x, y)
{
        ctx.drawImage(image,(tileNumber % tilesWide)*tileWidth, Math.floor(tileNumber / tilesWide) * tileHeight, tileWidth, tileHeight, x, y, tileWidth, tileHeight);
}

function putImageDataTile(ctx, imageDataCTX, tilesWide, tilesHigh, tileWidth, tileHeight, tileNumber, x, y)
{
        ctx.putImageData(imageDataCTX.getImageData((tileNumber % tilesWide)*tileWidth, Math.floor(tileNumber / tilesWide) * tileHeight, tileWidth, tileHeight), x, y, 0, 0, tileWidth, tileHeight);
}
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Using ctx.drawImage
for (r = 0; r < 5; r++) {
  for (y = 0; y < tilesHigh; y++) {
    for (x = 0; x < tilesWide; x++) {
      drawImageTile(drawImageCTX, tileImage, tilesWide, tilesHigh, tileWidth, tileHeight, x + y * tilesWide, x * tileWidth, y * tileHeight);
    }
  }
}
pending…
Using ctx.putImageData
for (r = 0; r < 5; r++) {
  for (y = 0; y < tilesHigh; y++) {
    for (x = 0; x < tilesWide; x++) {
      putImageDataTile(putImageDataCTX, tileImageCTX, tilesWide, tilesHigh, tileWidth, tileHeight, x + y * tilesWide, x * tileWidth, y * tileHeight);
    }
  }
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment