mirror of
https://github.com/danbulant/pngjs
synced 2026-06-20 15:01:33 +00:00
update readme, fix stlye issues
This commit is contained in:
parent
83d60edeaf
commit
6467ad747b
7 changed files with 16 additions and 14 deletions
|
|
@ -9,13 +9,14 @@ Based on [pngjs](https://github.com/niegowski/node-pngjs) with the follow enhanc
|
|||
* Support for reading 1,2,4 & 16 bit files
|
||||
* Support for reading interlace files
|
||||
* Support for reading `tTRNS` transparent colours
|
||||
* Support for writing colortype 2 (RGB) and colortype 6 (RGBA)
|
||||
* Sync interface as well as async
|
||||
* API compatible with pngjs and node-pngjs
|
||||
|
||||
Known lack of support for:
|
||||
|
||||
* Extended PNG e.g. Animation
|
||||
* Writing in different formats
|
||||
* Writing in different formats, colortype 0 (greyscale), colortype 3 (indexed color), colortype 4 (greyscale with alpha)
|
||||
* Synchronous write
|
||||
|
||||
Requirements
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ ChunkStream.prototype._process = function() {
|
|||
}
|
||||
}
|
||||
|
||||
if (this._buffers && this._buffers.length > 0 && this._buffers[0] == null) {
|
||||
if (this._buffers && this._buffers.length > 0 && this._buffers[0] === null) {
|
||||
this._end();
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
catch (ex) {
|
||||
this.emit('error', ex);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function filterSumSub(pxData, pxPos, byteWidth, BPP) {
|
|||
return sum;
|
||||
}
|
||||
|
||||
function filterUp(pxData, pxPos, byteWidth, rawData, rawPos, BPP) {
|
||||
function filterUp(pxData, pxPos, byteWidth, rawData, rawPos) {
|
||||
|
||||
for (var x = 0; x < byteWidth; x++) {
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ function filterUp(pxData, pxPos, byteWidth, rawData, rawPos, BPP) {
|
|||
}
|
||||
}
|
||||
|
||||
function filterSumUp(pxData, pxPos, byteWidth, BPP) {
|
||||
function filterSumUp(pxData, pxPos, byteWidth) {
|
||||
|
||||
var sum = 0;
|
||||
var length = pxPos + byteWidth;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ var filter = require('./filter-pack');
|
|||
var CrcStream = require('./crc');
|
||||
var constants = require('./constants');
|
||||
|
||||
var COLOR_TYPE_TRUECOLOR = 2;
|
||||
var COLOR_TYPE_TRUECOLOR_WITH_ALPHA = 6;
|
||||
var COLORTYPE_TRUECOLOR = 2;
|
||||
var COLORTYPE_TRUECOLOR_ALPHA = 6;
|
||||
|
||||
var Packer = module.exports = function(options) {
|
||||
Stream.call(this);
|
||||
|
|
@ -17,11 +17,11 @@ var Packer = module.exports = function(options) {
|
|||
this._options = options;
|
||||
|
||||
options.deflateChunkSize = options.deflateChunkSize || 32 * 1024;
|
||||
options.deflateLevel = options.deflateLevel != null ? options.deflateLevel : 9;
|
||||
options.deflateStrategy = options.deflateStrategy != null ? options.deflateStrategy : 3;
|
||||
options.deflateLevel = options.deflateLevel !== null ? options.deflateLevel : 9;
|
||||
options.deflateStrategy = options.deflateStrategy !== null ? options.deflateStrategy : 3;
|
||||
options.deflateFactory = options.deflateFactory || zlib.createDeflate;
|
||||
options.bitDepth = options.bitDepth || 8;
|
||||
options.colorType = (typeof options.colorType=="number") ? options.colorType : COLOR_TYPE_TRUECOLOR_WITH_ALPHA;
|
||||
options.colorType = (typeof options.colorType === 'number') ? options.colorType : COLORTYPE_TRUECOLOR_ALPHA;
|
||||
|
||||
this.readable = true;
|
||||
};
|
||||
|
|
@ -39,7 +39,7 @@ Packer.prototype.pack = function(data, width, height, gamma) {
|
|||
|
||||
// filter pixel data
|
||||
var bpp = 4;
|
||||
if (this._options.colorType === COLOR_TYPE_TRUECOLOR) {
|
||||
if (this._options.colorType === COLORTYPE_TRUECOLOR) {
|
||||
bpp = 3;
|
||||
}
|
||||
var filteredData = filter(data, width, height, this._options, bpp);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ var PNG = exports.PNG = function(options) {
|
|||
this.width = options.width || 0;
|
||||
this.height = options.height || 0;
|
||||
|
||||
this.data = this.width > 0 && this.height > 0
|
||||
? new Buffer(4 * this.width * this.height) : null;
|
||||
this.data = this.width > 0 && this.height > 0 ?
|
||||
new Buffer(4 * this.width * this.height) : null;
|
||||
|
||||
if (options.fill && this.data) {
|
||||
this.data.fill(0);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
"Luke Page",
|
||||
"Pietajan De Potter",
|
||||
"Steven Sojka",
|
||||
"liangzeng"
|
||||
"liangzeng",
|
||||
"Michael Vogt"
|
||||
],
|
||||
"homepage": "https://github.com/lukeapage/pngjs2",
|
||||
"keywords": [
|
||||
|
|
|
|||
BIN
test/bg.png
BIN
test/bg.png
Binary file not shown.
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 108 B |
Loading…
Reference in a new issue