Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/eronana/indexed-png
- Owner: Eronana
- Created: 2022-08-01T08:00:03.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-02T09:13:36.000Z (about 2 years ago)
- Last Synced: 2024-10-20T14:28:38.168Z (18 days ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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)));
})();
```