Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DieGo367 authored May 13, 2022
1 parent a7ba23f commit 840a807
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# deno_qoi
An encoder/decoder for the [QOI format](https://qoiformat.org/), written in TypeScript.

## Usage
### Encode / decode
```ts
import { encode, decode } from "https://raw.githubusercontent.com/DieGo367/deno_qoi/main/mod.ts";

// encode a 1x4 image consisting of 1 red, 1 green, 1 blue, and 1 black pixel
const data = new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 0, 0, 0, 255]);
const encodedImage = encode(data, 1, 4);

// decode from QOI data
const decodedImage = decode(encodedImage);

// you can also re-encode a decoded image
const reencodedImage = encode(decodedImage);
```

### Read / write files
```ts
import { readFile, writeFile } from "https://raw.githubusercontent.com/DieGo367/deno_qoi/main/mod.ts";

// read a QOI file as RGBA data
const image = await readFile("image.qoi");

// write the previous example image to a QOI file
const data = new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 0, 0, 0, 255]);
await writeFile("image.qoi", data, 1, 4);

// write a DecodedImage to a QOI file
await writeFile("image.qoi", image);
```

## See also
- The [QOI format specification](https://qoiformat.org/qoi-specification.pdf)
- [Dominic Szablewski](http://twitter.com/phoboslab) ([phoboslab.org](http://phoboslab.org/)) - creator of the QOI format.

0 comments on commit 840a807

Please sign in to comment.