Skip to content

Commit

Permalink
Use rgba4444 format for transparent animated GIFs
Browse files Browse the repository at this point in the history
  • Loading branch information
zk-phi committed Jun 22, 2024
1 parent 7d7c1a6 commit 7d33b93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gifworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const encoder = GIFEncoder();
ctx.addEventListener("message", (msg) => {
if (msg.data.addFrame) {
const { data, transparent, width, height, delay } = msg.data.addFrame;
const palette = quantize(data, 256, { oneBitAlpha: transparent });
const index = applyPalette(data, palette);
const format = transparent ? "rgba4444" : "rgb565";
const palette = quantize(data, 256, { format, oneBitAlpha: transparent });
const index = applyPalette(data, palette, format);
encoder.writeFrame(index, width, height, { palette, delay, transparent });
} else if (msg.data.finish) {
encoder.finish();
Expand Down

0 comments on commit 7d33b93

Please sign in to comment.