Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eronana/indexed-png

A PNG encoder to create indexed PNG images
https://github.com/eronana/indexed-png

Last synced: 10 days ago
JSON representation

A PNG encoder to create indexed PNG images

Awesome Lists containing this project

README

        

# indexed-png
A PNG encoder to create indexed PNG images

## Usage
```ts
import fs = require('fs');
import { createPNG } from 'indexed-png';
const palette = [];
for (let r = 0; r < 6; r++) {
for (let g = 0; g < 6; g++) {
for (let b = 0; b < 6; b++) {
palette.push((r * 0x33) | ((g * 0x33) << 8) | ((b * 0x33) << 16));
}
}
}

(async () => {
const width = 36;
const height = 6
const data = Buffer.from(Array(width * height).fill(0).map((_, i) => i % (6 * 6 * 6)));
fs.writeFileSync('test.png', (await createPNG(data, palette, width, height)));
})();
```