mirror of
https://github.com/danbulant/pngjs
synced 2026-07-06 11:40:43 +00:00
Fix issue interlacing small files
This commit is contained in:
parent
b9293eaa2b
commit
80addf080b
3 changed files with 7 additions and 2 deletions
|
|
@ -98,12 +98,13 @@ exports.dataToBitMap = function(data, width, height, bpp, depth, interlace) {
|
||||||
for(var imageIndex = 0; imageIndex < images.length; imageIndex++) {
|
for(var imageIndex = 0; imageIndex < images.length; imageIndex++) {
|
||||||
var imageWidth = images[imageIndex].width;
|
var imageWidth = images[imageIndex].width;
|
||||||
var imageHeight = images[imageIndex].height;
|
var imageHeight = images[imageIndex].height;
|
||||||
|
var imagePass = images[imageIndex].index;
|
||||||
for (var y = 0; y < imageHeight; y++) {
|
for (var y = 0; y < imageHeight; y++) {
|
||||||
for (var x = 0; x < imageWidth; x++) {
|
for (var x = 0; x < imageWidth; x++) {
|
||||||
if (depth !== 8) {
|
if (depth !== 8) {
|
||||||
pixelData = bits.get(bpp);
|
pixelData = bits.get(bpp);
|
||||||
}
|
}
|
||||||
var pxPos = getPxPos(x, y, imageIndex);
|
var pxPos = getPxPos(x, y, imagePass);
|
||||||
//console.log(x,y,imageIndex, pxPos);
|
//console.log(x,y,imageIndex, pxPos);
|
||||||
for (var i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
var idx = pixelBppMap[bpp][i];
|
var idx = pixelBppMap[bpp][i];
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ exports.getImagePasses = function(width, height) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (passWidth > 0 && passHeight > 0) {
|
if (passWidth > 0 && passHeight > 0) {
|
||||||
images.push({ width: passWidth, height: passHeight});
|
images.push({ width: passWidth, height: passHeight, index: i});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return images;
|
return images;
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,10 @@ Parser.prototype.reverseFiltered = function(indata, depth, width, height) {
|
||||||
var pxPos = pxRowPos + (x << 2),
|
var pxPos = pxRowPos + (x << 2),
|
||||||
color = this._palette[indata[pxPos]];
|
color = this._palette[indata[pxPos]];
|
||||||
|
|
||||||
|
if (!color) {
|
||||||
|
throw new Error("index " + indata[pxPos] + " not in palette");
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < 4; i++)
|
for (var i = 0; i < 4; i++)
|
||||||
indata[pxPos + i] = color[i];
|
indata[pxPos + i] = color[i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue