diff --git a/examples/test/bg.js b/examples/test/bg.js new file mode 100644 index 0000000..a38985c --- /dev/null +++ b/examples/test/bg.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node + +var fs = require('fs'), + PNG = require('pngjs').PNG; + + +var png = new PNG({ + width: 10, + height: 10, + filterType: -1 +}); + + +for (var y = 0; y < png.height; y++) { + for (var x = 0; x < png.width; x++) { + var idx = (png.width * y + x) << 2; + + var col = x < (png.width >> 1) ^ y < (png.height >> 1) ? 0xe5 : 0xff; + + png.data[idx ] = col; + png.data[idx+1] = col; + png.data[idx+2] = col; + png.data[idx+3] = 0xff; + } +} + +png.pipe(fs.createWriteStream('bg.png')); +png.pack(); diff --git a/examples/test/bg.png b/examples/test/bg.png new file mode 100644 index 0000000..491ae6e Binary files /dev/null and b/examples/test/bg.png differ diff --git a/examples/test/list.html b/examples/test/list.html index 1e3aa12..b2183fd 100644 --- a/examples/test/list.html +++ b/examples/test/list.html @@ -3,8 +3,8 @@ PNG Test diff --git a/lib/png.js b/lib/png.js index 693db79..87e2f47 100644 --- a/lib/png.js +++ b/lib/png.js @@ -52,6 +52,7 @@ util.inherits(PNG, Parser); PNG.prototype.pack = function() { this._pack(this.width, this.height, this.data); + return this; }; @@ -76,11 +77,13 @@ PNG.prototype.parse = function(data, callback) { } this._parse(data); + return this; }; PNG.prototype.write = function(data) { this._buffers.push(data); this._buffLen += data.length; + return true; }; PNG.prototype.end = function(data) {