Skip to Content
defold-typescript libraries
britzl

britzl/defold-imp/imp

Image processing on Defold buffers: 3x3 convolution kernels for blur, sharpen and edge detection.

  • GitHub: britzl/defold-imp — pinned to 1.1.0
    1. Pick a release from britzl/defold-imp releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as imp from "imp"

Functions

convolution(src: Opaque<"buffer">, dst: Opaque<"buffer">, width: number, height: number, kernel: [ number, number, number, number, number, number, number, number, number ])

Applies a row-major 3x3 convolution kernel to src and writes the result into dst. Both buffers must carry a uint8 rgb stream of three or four components per pixel and hold at least width * height elements. The call checks that each stream is uint8 and that the two streams' component counts match, but not either buffer's element count, so an undersized buffer is read or written past its end.

Parameters

  • src: Opaque<"buffer"> — The source buffer, read only.
  • dst: Opaque<"buffer"> — The destination buffer the result is written into.
  • width: number — Width of the image in pixels.
  • height: number — Height of the image in pixels.
  • kernel: [ number, number, number, number, number, number, number, number, number ] — The row-major 3x3 kernel, nine numbers.

On this page