Comparing version 0.1.0 to 0.2.0
@@ -20,3 +20,3 @@ | ||
this.data = new Buffer(this.stride * this.height); | ||
if (this.stride * this.height != 0 && this.data.length < this.stride * this.height) | ||
if (this.data && this.data.length < this.stride * (this.height - 1) + this.width * psize) | ||
throw new Error("image data too small"); | ||
@@ -62,1 +62,14 @@ } | ||
} | ||
Image.prototype.subView = function(x, y, w, h) { | ||
var p = this.pixelSize(); | ||
var off = y * this.stride + x * p; | ||
var len = (h - 1) * this.stride + w * p; | ||
return new Image({ | ||
width: w, | ||
height: h, | ||
pixel: this.pixel, | ||
stride: this.stride, | ||
data: this.data.slice(off, off + len) | ||
}); | ||
} |
{ | ||
"name": "picha", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "image format codec and simple image processing", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
77489
389