From 2334fc859a1eeac403a52cd71e7b78638d1ddcf2 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 15 Nov 2010 20:44:06 -0800 Subject: [PATCH] Added createImageData(ImageData) support --- lib/context2d.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/context2d.js b/lib/context2d.js index c7aa714..882ed2e 100644 --- a/lib/context2d.js +++ b/lib/context2d.js @@ -469,15 +469,20 @@ Context2d.prototype.getImageData = function(x, y, width, height){ }; /** - * Create `ImageData` with the given dimensions. + * Create `ImageData` with the given dimensions or + * `ImageData` instance for dimensions. * - * @param {Number} width + * @param {Number|ImageData} width * @param {Number} height * @return {ImageData} * @api public */ Context2d.prototype.createImageData = function(width, height){ + if (width instanceof ImageData) { + height = width.height; + width = width.width; + } var arr = new PixelArray(width, height); return new ImageData(arr); }; \ No newline at end of file