Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
feat(encode): ✨ support PLTE
Browse files Browse the repository at this point in the history
  • Loading branch information
vivaxy committed Dec 30, 2019
1 parent 9e95e10 commit e14dca8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/encode/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('encode', async function() {
// cwd: fixturesPath,
// onlyDirectories: true,
// });
const testcaseNames = ['chunk-IHDR'];
const testcaseNames = ['bit-depth-01'];

await Promise.all(
testcaseNames.map(async function(testcaseName) {
Expand Down
9 changes: 9 additions & 0 deletions src/encode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export default function encode(metadata: Metadata) {

function packPLTE() {
let data = new Uint8Array();
if (metadata.palette) {
for (let i = 0; i < metadata.palette.length; i++) {
const palette = metadata.palette[i];
data = concatUInt8Array(
data,
new Uint8Array([palette[0], palette[1], palette[2]]),
);
}
}
return data;
}

Expand Down

0 comments on commit e14dca8

Please sign in to comment.