Skip to content

Commit

Permalink
chore: update README.md to reflect changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackAsLight committed Nov 5, 2024
1 parent e2c4285 commit 245329b
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
# qoi

This is a TypeScript implementation of the `.qoi` image format. The module
provides two TransformStream classes to encode and decode
`ReadableStream<Uint8Array>` in the desired format. The raw pixel format pipped
into the encoder is expected to be a repeating sequence of `[ r, g, b, a ]`.
This is also the format that is pipped out of the decoder. This implementation
is based off the
This is a TypeScript implementation of the QOI image format. The module offers
both sync and streaming versions to encode and decode to and from the QOI image
format. The raw pixel format/ the decoded format is a repeating sequence of
`[ r, g, b, a ]` in a `Uint8Array`, `Uint8ClampedArray`, or a
`ReadableStream<Uint8Array>`.

This implementationis based off the
[QOI Specification](https://qoiformat.org/qoi-specification.pdf). You can find
about more about QOI at their website: https://qoiformat.org/.

## Example

```ts
import { QOIEncoderStream } from "@img/qoi";
import { encodeQOI } from "@img/qoi";

await ReadableStream
.from(async function* () {
for (let r = 0; r < 256; ++r) {
for (let c = 0; c < 256; ++c) {
yield Uint8Array.from([255 - r, c, r, 255]);
}
const rawData = await new Response(ReadableStream.from(async function* () {
for (let r = 0; r < 256; ++r) {
for (let c = 0; c < 256; ++c) {
yield Uint8Array.from([255 - r, c, r, 255]);
}
}())
.pipeThrough(
new QOIEncoderStream({
width: 256,
height: 256,
channels: "rgb",
colorspace: 0,
}),
)
.pipeTo((await Deno.create("image.qoi")).writable);
}
}())).bytes();

await Deno.writeFile(
"image.qoi",
encodeQOI(rawData, {
width: 256,
height: 256,
channels: "rgb",
colorspace: 0,
}),
);
```

0 comments on commit 245329b

Please sign in to comment.