Browse Source

Added createImageData(ImageData) support

v1.x
Tj Holowaychuk 14 years ago
parent
commit
2334fc859a
  1. 9
      lib/context2d.js

9
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 * @param {Number} height
* @return {ImageData} * @return {ImageData}
* @api public * @api public
*/ */
Context2d.prototype.createImageData = function(width, height){ Context2d.prototype.createImageData = function(width, height){
if (width instanceof ImageData) {
height = width.height;
width = width.width;
}
var arr = new PixelArray(width, height); var arr = new PixelArray(width, height);
return new ImageData(arr); return new ImageData(arr);
}; };
Loading…
Cancel
Save