-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update README.md to reflect changes
- Loading branch information
1 parent
e2c4285
commit 245329b
Showing
1 changed file
with
24 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}), | ||
); | ||
``` |