Skip to content
This repository was archived by the owner on Apr 22, 2021. It is now read-only.
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
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class PNG {
}
})();

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

Expand Down Expand Up @@ -185,7 +185,7 @@ class PNG {
const pixelBytes = this.pixelBitlength / 8;
const scanlineLength = pixelBytes * this.width;

const pixels = new Buffer(scanlineLength * this.height);
const pixels = Buffer.alloc(scanlineLength * this.height);
const {length} = data;
let row = 0;
let pos = 0;
Expand Down Expand Up @@ -288,7 +288,7 @@ class PNG {
decodePalette() {
const {palette} = this;
const transparency = this.transparency.indexed || [];
const ret = new Buffer(transparency.length + palette.length);
const ret = Buffer.alloc(transparency.length + palette.length);
let pos = 0;
const {length} = palette;
let c = 0;
Expand Down Expand Up @@ -361,7 +361,7 @@ 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