Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions PNGReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var zlib = require('zlib');
var PNG = require('./PNG');

var inflate = function(data, callback){
return zlib.inflate(new Buffer(data), callback);
return zlib.inflate(Buffer.from(data), callback);
};

var slice = Array.prototype.slice;
Expand Down Expand Up @@ -188,12 +188,12 @@ PNGReader.prototype.decodePixels = function(callback){
var length = 0;
var i, j, k, l;
for (l = this.dataChunks.length; l--;) length += this.dataChunks[l].length;
var data = new Buffer(length);
var data = new Array(length);
for (i = 0, k = 0, l = this.dataChunks.length; i < l; i++){
var chunk = this.dataChunks[i];
for (j = 0; j < chunk.length; j++) data[k++] = chunk[j];
}
inflate(data, function(err, data){
inflate(Buffer.from(data), function(err, data){
if (err) return callback(err);

try {
Expand Down Expand Up @@ -222,7 +222,7 @@ PNGReader.prototype.interlaceNone = function(data){
// color bytes per row
var cpr = bpp * png.width;

var pixels = new Buffer(bpp * png.width * png.height);
var pixels = new Array(bpp * png.width * png.height);
var scanline;
var offset = 0;

Expand All @@ -243,7 +243,7 @@ PNGReader.prototype.interlaceNone = function(data){

}

png.pixels = pixels;
png.pixels = Buffer.from(pixels);

};

Expand Down