Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsoding/bng
BNG Image Format Implementation
https://github.com/tsoding/bng
hacktoberfest hacktoberfest2020
Last synced: 5 days ago
JSON representation
BNG Image Format Implementation
- Host: GitHub
- URL: https://github.com/tsoding/bng
- Owner: tsoding
- License: mit
- Created: 2020-09-04T10:35:10.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-19T05:44:01.000Z (about 4 years ago)
- Last Synced: 2024-08-01T21:44:41.968Z (3 months ago)
- Topics: hacktoberfest, hacktoberfest2020
- Language: C
- Homepage:
- Size: 175 KB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Extending Native Browser Capabilities with WebAssembly
## Quick Start
```console
$ make -B
$ python -m SimpleHTTPServer 8080
$ iexplorer.exe http://localhost:8080/bng.html
```## Research Notes
- [x] Premise: Performance of WASM is probably comparable to native code
- [x] Let's check it by implementing a Prime Number Crunching as a "Benchmark":
- [x] https://github.com/tsoding/prime-benchmark
- [ ] Idea: Let's imagine we invented a new image format that didn't exist before
- [ ] If we implement the image support in WASM can we make it feel like a native browser support
- [x] [Implement png2bng](./png2bng.c)
- [x] [Implement bngviewer](./bngviewer.c)
- [x] Implement bng support in WASM
- [x] fetch("tsodinw.bng"):
```js
fetch("./tsodinw.bng").then((x) => console.log(x.arrayBuffer()))
```
- [x] Put the fetched file into WASM memory
```js
let bngFile = await fetch("tsodinw.bng");
let fileData = await bngFile.arrayBuffer();
let memory = new WebAssembly.Memory({initial: 10, maximum: 10});
new Uint8Array(memory.buffer).set(new Uint8Array(fileData));
```
- [x] Call a WASM function that turns the file into Image Data
- [x] Take out the Image Data from WASM memory and display it
- [x] Add more interesting features to bng to test the support
- [x] Different pixel formats
- [x] Different compressions
- [ ] Reusable BNG library that works both natively and being compiled to WASM
- [ ] Check out this article: https://surma.dev/things/c-to-webassembly/
- [ ] img tag integration
- [ ] Check out object URLs: https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL