default

ICO/CUR icon directory encoding and decoding.

Examples

Round-trip a directory with one entry

import { assertEquals } from "@std/assert";
import { icoDir, ICO_IMAGE_TYPE } from "@binstruct/ico";

const coder = icoDir();
const dir = {
  reserved: 0,
  imageType: ICO_IMAGE_TYPE.ICON,
  imageCount: 1,
  entries: [
    {
      width: 32,
      height: 32,
      colorCount: 0,
      reserved: 0,
      planes: 1,
      bitCount: 32,
      dataSize: 744,
      dataOffset: 22,
    },
  ],
};

const buffer = new Uint8Array(64);
const written = coder.encode(dir, buffer);
const [decoded, read] = coder.decode(buffer.subarray(0, written));

assertEquals(written, read);
assertEquals(decoded, dir);

Functions

f
icoDir(): Coder<IcoDir>

Creates a coder for an ICO/CUR icon directory.

Interfaces

Variables

v
ICO_IMAGE_TYPE: { ICON: number; CURSOR: number; }

Values used by the ICONDIR.imageType field.

v
ICONDIR_SIZE: 6

Size in bytes of the ICONDIR header (reserved + imageType + imageCount), before the entry array.

v
ICONDIRENTRY_SIZE: 16

Size in bytes of a single ICONDIRENTRY record.