byte-codec 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -10
- package/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -185,13 +185,13 @@ function unfilterScanlines(data, height, bytesPerRow, bpp) {
|
|
|
185
185
|
const rowStart = y * stride + 1;
|
|
186
186
|
const outRowStart = y * bytesPerRow;
|
|
187
187
|
const prevOutRowStart = y > 0 ? outRowStart - bytesPerRow : void 0;
|
|
188
|
-
|
|
188
|
+
out.subarray(outRowStart, outRowStart + bytesPerRow).forEach((_value, x) => {
|
|
189
189
|
const raw = data[rowStart + x];
|
|
190
190
|
const a = x >= bpp ? out[outRowStart + x - bpp] : 0;
|
|
191
191
|
const b = prevOutRowStart === void 0 ? 0 : out[prevOutRowStart + x];
|
|
192
192
|
const c = x >= bpp && prevOutRowStart !== void 0 ? out[prevOutRowStart + x - bpp] : 0;
|
|
193
193
|
out[outRowStart + x] = raw + predictorValue(filterByte, a, b, c) & 255;
|
|
194
|
-
}
|
|
194
|
+
});
|
|
195
195
|
}
|
|
196
196
|
return out;
|
|
197
197
|
}
|
|
@@ -201,13 +201,13 @@ function sumOfAbsSigned(bytes) {
|
|
|
201
201
|
return sum;
|
|
202
202
|
}
|
|
203
203
|
function filterRowInto(raw, rowStart, prevRowStart, bytesPerRow, bpp, filterType, out, outOffset) {
|
|
204
|
-
|
|
204
|
+
out.subarray(outOffset, outOffset + bytesPerRow).forEach((_byte, x) => {
|
|
205
205
|
const rawByte = raw[rowStart + x];
|
|
206
206
|
const a = x >= bpp ? raw[rowStart + x - bpp] : 0;
|
|
207
207
|
const b = prevRowStart === void 0 ? 0 : raw[prevRowStart + x];
|
|
208
208
|
const c = x >= bpp && prevRowStart !== void 0 ? raw[prevRowStart + x - bpp] : 0;
|
|
209
209
|
out[outOffset + x] = rawByte - predictorValue(filterType, a, b, c) & 255;
|
|
210
|
-
}
|
|
210
|
+
});
|
|
211
211
|
}
|
|
212
212
|
const ALL_FILTER_TYPES = [
|
|
213
213
|
0,
|
|
@@ -348,12 +348,11 @@ function writeTruecolorPng(writer, image, options) {
|
|
|
348
348
|
const bytesPerRow = width * outChannels;
|
|
349
349
|
const pixelCount = width * height;
|
|
350
350
|
const interleaved = new Uint8Array(pixelCount * outChannels);
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
351
|
+
interleaved.forEach((_byte, index) => {
|
|
352
|
+
const pixel = Math.floor(index / outChannels);
|
|
353
|
+
const channel = index % outChannels;
|
|
354
|
+
interleaved[index] = alpha !== void 0 && channel === channels ? alpha[pixel] : data[pixel * channels + channel];
|
|
355
|
+
});
|
|
357
356
|
writeIhdr(writer, width, height, colorTypeFor(image));
|
|
358
357
|
writeChunk(writer, "IDAT", deflate(filterScanlines(interleaved, height, bytesPerRow, outChannels, options.filter ?? "adaptive")));
|
|
359
358
|
}
|
package/dist/index.js
CHANGED
|
@@ -184,13 +184,13 @@ function unfilterScanlines(data, height, bytesPerRow, bpp) {
|
|
|
184
184
|
const rowStart = y * stride + 1;
|
|
185
185
|
const outRowStart = y * bytesPerRow;
|
|
186
186
|
const prevOutRowStart = y > 0 ? outRowStart - bytesPerRow : void 0;
|
|
187
|
-
|
|
187
|
+
out.subarray(outRowStart, outRowStart + bytesPerRow).forEach((_value, x) => {
|
|
188
188
|
const raw = data[rowStart + x];
|
|
189
189
|
const a = x >= bpp ? out[outRowStart + x - bpp] : 0;
|
|
190
190
|
const b = prevOutRowStart === void 0 ? 0 : out[prevOutRowStart + x];
|
|
191
191
|
const c = x >= bpp && prevOutRowStart !== void 0 ? out[prevOutRowStart + x - bpp] : 0;
|
|
192
192
|
out[outRowStart + x] = raw + predictorValue(filterByte, a, b, c) & 255;
|
|
193
|
-
}
|
|
193
|
+
});
|
|
194
194
|
}
|
|
195
195
|
return out;
|
|
196
196
|
}
|
|
@@ -200,13 +200,13 @@ function sumOfAbsSigned(bytes) {
|
|
|
200
200
|
return sum;
|
|
201
201
|
}
|
|
202
202
|
function filterRowInto(raw, rowStart, prevRowStart, bytesPerRow, bpp, filterType, out, outOffset) {
|
|
203
|
-
|
|
203
|
+
out.subarray(outOffset, outOffset + bytesPerRow).forEach((_byte, x) => {
|
|
204
204
|
const rawByte = raw[rowStart + x];
|
|
205
205
|
const a = x >= bpp ? raw[rowStart + x - bpp] : 0;
|
|
206
206
|
const b = prevRowStart === void 0 ? 0 : raw[prevRowStart + x];
|
|
207
207
|
const c = x >= bpp && prevRowStart !== void 0 ? raw[prevRowStart + x - bpp] : 0;
|
|
208
208
|
out[outOffset + x] = rawByte - predictorValue(filterType, a, b, c) & 255;
|
|
209
|
-
}
|
|
209
|
+
});
|
|
210
210
|
}
|
|
211
211
|
const ALL_FILTER_TYPES = [
|
|
212
212
|
0,
|
|
@@ -347,12 +347,11 @@ function writeTruecolorPng(writer, image, options) {
|
|
|
347
347
|
const bytesPerRow = width * outChannels;
|
|
348
348
|
const pixelCount = width * height;
|
|
349
349
|
const interleaved = new Uint8Array(pixelCount * outChannels);
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
350
|
+
interleaved.forEach((_byte, index) => {
|
|
351
|
+
const pixel = Math.floor(index / outChannels);
|
|
352
|
+
const channel = index % outChannels;
|
|
353
|
+
interleaved[index] = alpha !== void 0 && channel === channels ? alpha[pixel] : data[pixel * channels + channel];
|
|
354
|
+
});
|
|
356
355
|
writeIhdr(writer, width, height, colorTypeFor(image));
|
|
357
356
|
writeChunk(writer, "IDAT", deflate(filterScanlines(interleaved, height, bytesPerRow, outChannels, options.filter ?? "adaptive")));
|
|
358
357
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "byte-codec",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "Generic byte-level primitives (ByteWriter, ByteReader, CRC-32, deflate/inflate) and PNG/JPEG image encoding/decoding with zero PDF knowledge — the shared utility package for the documents.js family.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|