sfml.js
    Preparing search index...

    Class Image

    Native-owned RGBA8 pixels with asynchronous file and codec operations.

    Index

    Constructors

    Properties

    "[graphicsNative]": NativeGraphicsHandle<"image">

    Accessors

    • get pixels(): Uint8Array

      Writable extension; old views retain old images after resize or load.

      Returns Uint8Array

    Methods

    • Empty images have no pixel pointer. Constness is enforced by TypeScript.

      Returns
          | undefined
          | Readonly<
              Pick<
                  Uint8Array,
                  | number
                  | typeof iterator
                  | "length"
                  | "slice"
                  | "entries"
                  | "keys"
                  | "values"
                  | "byteLength"
                  | "byteOffset",
              >,
          >

    • 异步读取并解码图像文件,成功后替换像素存储,返回是否成功。

      Parameters

      • filename: string

      Returns Promise<boolean>

    • 异步解码 PNG/JPEG 等编码图像字节,返回是否成功。

      Parameters

      • data: Uint8Array

      Returns Promise<boolean>

    • 按文件扩展名异步编码并保存图像,返回是否成功。

      Parameters

      • filename: string

      Returns Promise<boolean>

    • 异步编码为 format(如 png)指定的格式,返回字节;编码失败返回 undefined。

      Parameters

      • format: string

      Returns Promise<undefined | Uint8Array>