checked background on test page

This commit is contained in:
Kuba Niegowski 2012-08-20 23:32:20 +02:00
parent dc024a1b35
commit 207c02d323
4 changed files with 33 additions and 2 deletions

28
examples/test/bg.js Normal file
View file

@ -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();

BIN
examples/test/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

View file

@ -3,8 +3,8 @@
<head>
<title>PNG Test</title>
<style>
body { background: #0f0; font: 12px Arial; margin: 10px; }
img { margin: 2px; }
body { background: #eee; font: 12px Arial; margin: 10px; }
img { margin: 2px; background: url(bg.png); }
h3 { margin: 10px 0; }
</style>
</head>

View file

@ -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) {