This commit is contained in:
Kuba Niegowski 2012-08-19 23:36:53 +02:00
parent 66c0a34c7a
commit 2fe6c8805a

View file

@ -92,3 +92,25 @@ PNG.prototype._metadata = function(width, height) {
this.height = height; this.height = height;
this.data = null; this.data = null;
}; };
PNG.prototype.bitblt = function(dst, sx, sy, w, h, dx, dy) {
var src = this;
if (sx > src.width || sy > src.height
|| sx + w > src.width || sy + h > src.height)
throw new Error('bitblt reading outside image');
if (dy > dst.width || dy > dst.height
|| dx + w > dst.width || dy + h > dst.height)
throw new Error('bitblt writing outside image');
for (var y = 0; y < h; y++) {
src.data.copy(dst.data,
((dy + y) * dst.width + dx) << 2,
((sy + y) * src.width + sx) << 2,
((sy + y) * src.width + sx + w) << 2
);
}
return this;
};