Class PixelUtil

Utility methods for converting and managing pixel data and formats.

Hierarchy

  • FrameworkObject
    • PixelUtil

Constructors

  • Parameters

    • OptionalisInternalConstructor: boolean

    Returns PixelUtil

Methods

  • Converts pixels from one format to another. Provided pixel data objects must have previously allocated buffers of adequate size and their sizes must match.

    Parameters

    Returns AsyncOp<PixelData, void>

  • Converts color temperature in Kelvins into an RGB color.

    Parameters

    • temperature: number

    Returns Color

  • Converts a cubemap into a cylindrical panoramic map.

    Parameters

    • faceData: PixelData[]

      Pixels for each individual face of the cubemap, in order as specified by CubemapFace enum.

    • output: PixelData

      Pre-allocated 2D buffer to receive the cylindrical panoramic map. It is suggested the buffer's width is twice the height.

    Returns void

  • Creates a grayscale pixel data from the given source image, using the given channel.

    Parameters

    • source: PixelData

      The source image to create the grayscale from.

    • channel: EnumValue<ChannelMask, number>

      The pixel channel to retrieve the pixel data information from.

    Returns PixelData

    The pixel data that represents a grayscale information image from the given source.

  • Creates a grayscale pixel data from the given source image, using the given channel.

    Parameters

    Returns void

    The pixel data that represents a grayscale information image from the given source.

  • Returns the dimensions of a single compressed block, in number of pixels. Returns 1x1 for non-block-compressed formats.

    Parameters

    Returns Vector2

  • Returns the size of a single compressed block, in bytes. Returns pixel size if the format is not block compressed.

    Parameters

    Returns number

  • Returns the size of a single pixel of the provided pixel format, in bits.

    Parameters

    Returns number

  • Returns the size of a single pixel of the provided pixel format, in bytes.

    Parameters

    Returns number

  • Returns the number of pixel elements in the provided format.

    Parameters

    Returns number

  • Returns the maximum number of mip maps that can be generated until we reach the minimum size possible. This does not count the base level.

    Parameters

    Returns number

  • Returns the size of the memory region required to hold pixels of the provided size and format.

    Parameters

    • width: number
    • height: number
    • depth: number
    • format: EnumValue<PixelFormat, number>
    • OptionalfaceCount: number
    • OptionalmipCount: number

    Returns number

  • Calculates row and depth pitch for a texture surface of the specified size and format. For most formats row pitch will equal the number of bytes required for storing "width" pixels, and slice pitch will equal the number of bytes required for storing "width*height" pixels. But some texture formats (especially compressed ones) might require extra padding. Input width/height/depth values are in pixels, while output pitch values are in bytes.

    Parameters

    Returns Vector2

  • Finds a PixelFormat value that has a given name.

    Parameters

    • name: string

      Name of PixelFormat to search for.

    Returns EnumValue<PixelFormat, number>

    PixelFormat that matches given name or PixelFormat::Unknown if not found.

  • Returns the name of the pixel format.

    Parameters

    Returns string

  • Calculates the size of a mip level of a texture with the provided size.

    Parameters

    • width: number
    • height: number
    • depth: number
    • mipLevel: number

    Returns Vector3

  • Checks if the provided pixel format has an alpha channel.

    Parameters

    Returns boolean

  • Returns true if the pixel data in the format can be directly accessed and read. This is generally not true for compressed formats.

    Parameters

    Returns boolean

  • Creates a grayscale pixel data from the given source image, using the given channel.

    Parameters

    Returns boolean

    The pixel data that represents a grayscale information image from the given source.

  • Checks is the provided pixel format compressed.

    Parameters

    Returns boolean

  • Checks is the provided pixel format a depth/stencil buffer format.

    Parameters

    Returns boolean

  • Checks is the provided pixel format a floating point format.

    Parameters

    Returns boolean

  • Determines if the specified format format is a single channel grayscale format.

    Parameters

    Returns boolean

  • Checks does the provided format store data in normalized range.

    Parameters

    Returns boolean

  • Checks does the provided format store data in normalized range.

    Parameters

    Returns boolean

  • Converts pixel data in linear space to one in sRGB space. Only converts the RGB components.

    Parameters

    Returns void

  • Mirrors the contents of the provided object along the X, Y and/or Z axes.

    Parameters

    Returns void

  • Saves the provided pixels as an image at the specified file path and file format. If file path extension is not provided one will be appended based on the selected format.

    Parameters

    Returns void

  • Scales the input texture so it matches the size of the output texture. The operation will be performed asynchonously on the GPU.

    Parameters

    Returns void

  • Converts pixel data in sRGB space to one in linear space. Only converts the RGB components.

    Parameters

    Returns void