From 245329b3965b2855f664d3d63e966a38c5e6aec4 Mon Sep 17 00:00:00 2001 From: BlackAsLight <44320105+BlackAsLight@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:59:18 +1100 Subject: [PATCH] chore: update README.md to reflect changes --- README.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 941c61c..9a36b70 100644 --- a/README.md +++ b/README.md @@ -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` 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`. + +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, + }), +); ```