Skip to content

ImageFormat

Type

ImageFormat

The ImageFormat type is a handler for an image format that SLADE supports (eg. Doom Gfx), with the ability to read from or write to an Image.

Constants

Name Value
WRITABLE_NO 0
WRITABLE_YES 1
WRITABLE_NEEDS_CONVERSION 2

Properties

Property Type Description
id string The format id
name string The name of the image format
extension string The file extension to use for images of this type

Constructors

No Constructors

This type can not be created directly in scripts.

See:

Functions

Overview

General

IsThisFormat(data) -> boolean LoadImage(image, data, [index]) -> boolean SaveImage(image, dataOut, [palette], [index]) -> boolean CanWrite(image) -> integer CanWritePixelFormat(pixelFormat) -> boolean ConvertWritable(image, convertOptions) -> boolean


IsThisFormat

Checks if the given data is an image of this format.

Parameters

Returns

  • boolean: true if the given data is an image of this format

LoadImage

Loads data of this format into image.

Parameters

  • image (Image): The target image to load the data into
  • data (DataBlock): The data to load
  • [index] (integer): The index of the image in the data (for cases where the image format contains multiple images, eg. Duke3D ART). Default is 0

Returns

  • boolean: true on success

SaveImage

Saves the given image to dataOut in this format.

Parameters

  • image (Image): The image to write
  • dataOut (DataBlock): The data block to write to
  • [palette] (Palette): The palette to use if image is 8-bit indexed but does not contain its own internal palette. Default is nil
  • [index] (integer): The index to write the image to in the data (for cases where the image format contains multiple images, eg. Duke3D ART). Default is 0

Returns

  • boolean: true on success

CanWrite

Checks if the given image can be written in this format.

Parameters

  • image (Image): The image to check

Returns

  • integer: Whether the given image can be saved as this format:
    • WRITABLE_NO: Can't be written
    • WRITABLE_YES: Can be written
    • WRITABLE_NEEDS_CONVERSION: Can't be written as-is, requires conversion to a supported pixel format first (see ConvertWritable)

CanWritePixelFormat

Parameters

  • pixelFormat (integer): The image pixel format to check (see Image.PIXELFORMAT_ constants)

Returns

  • boolean: true if this image format supports the given pixelFormat

ConvertWritable

Converts the given image so that it can be written in this format.

Parameters

  • image (Image): The image to convert
  • convertOptions (ImageConvertOptions): Options for converting the image to this format

Returns

  • boolean: true if the image was converted successfully and can now be written in this format