Options
All
  • Public
  • Public/Protected
  • All
Menu

Can be used to create, load, save and modify images.

Also useful when writing an importer, where the image can be set on a tileset (Tileset.loadFromImage), its tiles (Tile.setImage) or an image layer (ImageLayer.setImage).

since

1.5

Hierarchy

  • Image

Index

Constructors

constructor

  • new Image(): Image
  • new Image(width: number, height: number, format: number): Image
  • new Image(data: ArrayBuffer, width: number, height: number, format: number): Image
  • new Image(data: ArrayBuffer, width: number, height: number, bytesPerLine: number, format: number): Image
  • new Image(fileName: string, format?: string): Image
  • Constructs an empty image.

  • Constructs an image of the given size using the given format. The format is defined by one of the Image.Format_ values.

  • Constructs an image from the given data, interpreting it in the specified format and size. The format is defined by one of the Image.Format_ values.

  • Constructs an image from the given data, interpreting it in the specified format and size. The bytesPerLine argument specifies the stride and can be useful for referencing a sub-image. The format is defined by one of the Image.Format_ values.

  • Construct an image by loading it from the given file name. When no format is given it will be auto-detected (can be "bmp", "png", etc.).

Properties

Readonly depth

depth: number

Number of bits used to store a single pixel.

Readonly format

format: number

Format of the image. The format is defined by one of the Image.Format_ values.

Readonly height

height: number

Height of the image in pixels.

Readonly size

size: size

Size of the image in pixels.

Readonly width

width: number

Width of the image in pixels.

Static Readonly FastTransformation

FastTransformation: typeof FastTransformation

Static Readonly Format_A2BGR30_Premultiplied

Format_A2BGR30_Premultiplied: typeof Format_A2BGR30_Premultiplied

Static Readonly Format_A2RGB30_Premultiplied

Format_A2RGB30_Premultiplied: typeof Format_A2RGB30_Premultiplied

Static Readonly Format_ARGB32

Format_ARGB32: typeof Format_ARGB32

Static Readonly Format_ARGB32_Premultiplied

Format_ARGB32_Premultiplied: typeof Format_ARGB32_Premultiplied

Static Readonly Format_ARGB4444_Premultiplied

Format_ARGB4444_Premultiplied: typeof Format_ARGB4444_Premultiplied

Static Readonly Format_ARGB6666_Premultiplied

Format_ARGB6666_Premultiplied: typeof Format_ARGB6666_Premultiplied

Static Readonly Format_ARGB8555_Premultiplied

Format_ARGB8555_Premultiplied: typeof Format_ARGB8555_Premultiplied

Static Readonly Format_ARGB8565_Premultiplied

Format_ARGB8565_Premultiplied: typeof Format_ARGB8565_Premultiplied

Static Readonly Format_Alpha8

Format_Alpha8: typeof Format_Alpha8

Static Readonly Format_BGR30

Format_BGR30: typeof Format_BGR30

Static Readonly Format_BGR888

Format_BGR888: typeof Format_BGR888

Static Readonly Format_Grayscale16

Format_Grayscale16: typeof Format_Grayscale16

Static Readonly Format_Grayscale8

Format_Grayscale8: typeof Format_Grayscale8

Static Readonly Format_Indexed8

Format_Indexed8: typeof Format_Indexed8

Static Readonly Format_Invalid

Format_Invalid: typeof Format_Invalid

Static Readonly Format_Mono

Format_Mono: typeof Format_Mono

Static Readonly Format_MonoLSB

Format_MonoLSB: typeof Format_MonoLSB

Static Readonly Format_RGB16

Format_RGB16: typeof Format_RGB16

Static Readonly Format_RGB30

Format_RGB30: typeof Format_RGB30

Static Readonly Format_RGB32

Format_RGB32: typeof Format_RGB32

Static Readonly Format_RGB444

Format_RGB444: typeof Format_RGB444

Static Readonly Format_RGB555

Format_RGB555: typeof Format_RGB555

Static Readonly Format_RGB666

Format_RGB666: typeof Format_RGB666

Static Readonly Format_RGB888

Format_RGB888: typeof Format_RGB888

Static Readonly Format_RGBA64

Format_RGBA64: typeof Format_RGBA64

Static Readonly Format_RGBA64_Premultiplied

Format_RGBA64_Premultiplied: typeof Format_RGBA64_Premultiplied

Static Readonly Format_RGBA8888

Format_RGBA8888: typeof Format_RGBA8888

Static Readonly Format_RGBA8888_Premultiplied

Format_RGBA8888_Premultiplied: typeof Format_RGBA8888_Premultiplied

Static Readonly Format_RGBX64

Format_RGBX64: typeof Format_RGBX64

Static Readonly Format_RGBX8888

Format_RGBX8888: typeof Format_RGBX8888

Static Readonly IgnoreAspectRatio

IgnoreAspectRatio: typeof IgnoreAspectRatio

Static Readonly KeepAspectRatio

KeepAspectRatio: typeof KeepAspectRatio

Static Readonly KeepAspectRatioByExpanding

KeepAspectRatioByExpanding: typeof KeepAspectRatioByExpanding

Static Readonly SmoothTransformation

SmoothTransformation: typeof SmoothTransformation

Methods

color

  • color(index: number): number
  • Returns the 32-bit color value at the given index in the color table.

colorTable

  • colorTable(): number[]
  • Returns the color table as an array of 32-bit color values.

copy

  • copy(x: number, y: number, width: number, height: number): Image
  • Copies the given rectangle to a new image object.

fill

  • fill(index_or_rgb: number): void
  • fill(color: string): void
  • Fills the image with the given 32-bit unsigned color value (ARGB) or color table index.

  • Fills the image with the given color by string (supports values like "#rrggbb").

load

  • load(fileName: string, format?: string): void
  • Loads the image from the given file name. When no format is given it will be auto-detected (can be "bmp", "png", etc.).

loadFromData

  • loadFromData(data: ArrayBuffer, format: string): void
  • Loads the image from the given data interpreted with the given format (can be "bmp", "png", etc.).

mirrored

  • mirrored(horizontal: boolean, vertical: boolean): Image
  • Returns a mirrored copy of this image.

pixel

  • pixel(x: number, y: number): number
  • Returns the 32-bit unsigned color value (in ARGB order).

pixelColor

  • pixelColor(x: number, y: number): string
  • Returns the color at the given position as string like "#rrggbb".

save

  • save(fileName: string, format?: string, quality?: number): boolean
  • Saves the image to the given file.

    When no format is given it will be auto-detected based on the file extension.

saveToData

  • saveToData(format: string, quality?: number): ArrayBuffer
  • Saves the image to an ArrayBuffer in the given format (can be "bmp", png", etc.).

scaled

  • Returns a scaled copy of this image. Default aspectRatioMode behavior is to ignore the aspect ratio. Default mode is a fast transformation.

setColor

  • setColor(index: number, rgb: number): void
  • setColor(index: number, color: string): void
  • Sets the color at the given index in the color table to a given 32-bit color value.

  • Sets the color at the given index in the color table to a color by string (supports values like "#rrggbb").

setColorTable

  • setColorTable(colors: string[] | number[]): void
  • Sets the color table given by an array of either 32-bit color values or strings (supports values like "#rrggbb").

setPixel

  • setPixel(x: number, y: number, index_or_rgb: number): void
  • Sets the color at the specified location to the given 32-bit unsigned color value (ARGB) or color table index.

setPixelColor

  • setPixelColor(x: number, y: number, color: string): void
  • Sets the color at the specified location to the given color by string (supports values like "#rrggbb").

Generated using TypeDoc