@4bitlabs/image
TypeScript icon, indicating that this package has built-in type declarations

3.3.9 • Public • Published

@4bitlabs/image License NPM Version NPM Downloads

A collection of image primitives and manipulation functions for rendering Sierra On-line SCI-engine assets.

Palette Filter

The createPaletteFilter() function generates a palette filter for processing 4-bit pixel data from view, cursor, and font assets.

import { Palettes } from '@4bitlabs/color';
import { createPaletteFilter } from '@4bitlabs/image';

// Generate a classic 1x1 EGA dither
const dither = createPaletteFilter(Palettes.CGA);
const ouput = dither(visual);

Dither Filter

The createDitherFilter() function generates a dither filter for processing 8-bit dither-pairs from raw render data of visual layer SCI-engine PIC assets.

import { Dithers } from '@4bitlabs/color';
import { createDitherFilter } from '@4bitlabs/image';

// Generate a classic 1x1 EGA dither
const dither = createDitherFilter(Dithers.CGA);
const ouput = dither(visual);

Executing Pipelines

You can also execute more complex transformation pipelines with renderPixelData() for both paletted and dithered pixel-data.

import { Palette, Dithers } from '@4bitlabs/color';
import { scale5x6 } from '@4bitlabs/blur-filters';
import { hBoxBlur } from '@4bitlabs/blur-filters';
import {
  renderPixelData,
  createDitherFilter,
  type RenderPipeline,
} from '@4bitlabs/image';

const imageData = renderPixelData(visual, {
  // First, scale the image using the scale5x6 algorithm
  pre: [scale5x6],
  // Dither with CGA pairs, using a 5 by 6 pattern
  dither: createDitherFilter(Dithers.CGA, [5, 6]),
  // Finally, apply a horizontal box blur to the image
  post: [hBoxBlur(3)], //
});

Readme

Keywords

none

Package Sidebar

Install

npm i @4bitlabs/image

Weekly Downloads

3

Version

3.3.9

License

ISC

Unpacked Size

31.1 kB

Total Files

47

Last publish

Collaborators

  • 32bitkid