Skip to content

API reference / @jsprismarine/java-packs / image

image ​

Interfaces ​

RgbaImage ​

Defined in: image.ts:8

An image as eight-bit RGBA rows, top row first.

Properties ​

height ​

readonly height: number

Defined in: image.ts:10

pixels ​

readonly pixels: Uint8Array

Defined in: image.ts:12

width * height * 4 bytes: red, green, blue and alpha for each pixel.

width ​

readonly width: number

Defined in: image.ts:9

Type Aliases ​

TgaProblem ​

TgaProblem = object

Defined in: image.ts:16

Why a TGA did not decode, for the conversion report.

Properties ​

ok ​

readonly ok: false

Defined in: image.ts:16

reason ​

readonly reason: string

Defined in: image.ts:16

Functions ​

decodePng() ​

decodePng(bytes): TgaProblem | object & RgbaImage

Defined in: image.ts:252

Reads a PNG file of any color type and bit depth, plain or Adam7 interlaced, with its palette and tRNS transparency. A 16-bit channel keeps its high byte.

Parameters ​

bytes ​

Uint8Array

Returns ​

TgaProblem | object & RgbaImage

The image, or why it did not read.


decodeTga() ​

decodeTga(bytes): TgaProblem | object & RgbaImage

Defined in: image.ts:31

Reads a TGA file: color-mapped, true color or grayscale, plain or run-length encoded, at 8, 16, 24 or 32 bits a pixel, with its origin at either the bottom or the top left. Those cover every TGA in Mojang's vanilla resource pack.

Parameters ​

bytes ​

Uint8Array

Returns ​

TgaProblem | object & RgbaImage

The image, or why it did not read.


encodePng() ​

encodePng(__namedParameters): Uint8Array

Defined in: image.ts:153

Writes an image as an eight-bit RGBA PNG, every row unfiltered. The same image always gives the same bytes with the same zlib build, which keeps a converted pack's hash stable.

Parameters ​

__namedParameters ​

RgbaImage

Returns ​

Uint8Array


isPng() ​

isPng(bytes): boolean

Defined in: image.ts:178

Whether bytes start with the PNG signature.

Parameters ​

bytes ​

Uint8Array

Returns ​

boolean