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 png-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = class PNG {
break;
}

this.imgData = new Buffer(this.imgData);
this.imgData = Buffer.from(this.imgData);
return;
break;

Expand Down Expand Up @@ -188,15 +188,15 @@ module.exports = class PNG {
const { width, height } = this;
const pixelBytes = this.pixelBitlength / 8;

const pixels = new Buffer(width * height * pixelBytes);
const pixels = Buffer.alloc(width * height * pixelBytes);
const { length } = data;
let pos = 0;

function pass(x0, y0, dx, dy, singlePass = false) {
const w = Math.ceil((width - x0) / dx);
const h = Math.ceil((height - y0) / dy);
const scanlineLength = pixelBytes * w;
const buffer = singlePass ? pixels : new Buffer(scanlineLength * h);
const buffer = singlePass ? pixels : Buffer.alloc(scanlineLength * h);
let row = 0;
let c = 0;
while (row < h && pos < length) {
Expand Down Expand Up @@ -337,7 +337,7 @@ module.exports = class PNG {
const { palette } = this;
const { length } = palette;
const transparency = this.transparency.indexed || [];
const ret = new Buffer(transparency.length + length);
const ret = Buffer.alloc(transparency.length + length);
let pos = 0;
let c = 0;

Expand Down Expand Up @@ -393,7 +393,7 @@ module.exports = class PNG {
}

decode(fn) {
const ret = new Buffer(this.width * this.height * 4);
const ret = Buffer.alloc(this.width * this.height * 4);
return this.decodePixels(pixels => {
this.copyToImageData(ret, pixels);
return fn(ret);
Expand Down