From 207c02d3239000641f6b303a646f8c97ef2070e1 Mon Sep 17 00:00:00 2001 From: Kuba Niegowski Date: Mon, 20 Aug 2012 23:32:20 +0200 Subject: [PATCH] checked background on test page --- examples/test/bg.js | 28 ++++++++++++++++++++++++++++ examples/test/bg.png | Bin 0 -> 95 bytes examples/test/list.html | 4 ++-- lib/png.js | 3 +++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 examples/test/bg.js create mode 100644 examples/test/bg.png 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 0000000000000000000000000000000000000000..491ae6ead4243a931812ff4b6882768419fb13e6 GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4sd>6MhE&{2{=?70lkwo@=JXd% tJU%=wO^qQOMHW`mCQUkY!1<@O1TaS?83{1ORIs9Mu2- literal 0 HcmV?d00001 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) {