Search Results for

    Show / Hide Table of Contents

    Class ColorPalette

    A representation of a 256 indexed color palette in DAC format [0..63].

    Inheritance
    Object
    ColorPalette
    Implements
    IEnumerable<Color>
    Namespace: DIV2.Format.Exporter
    Assembly: DIV2.Format.Exporter.dll
    Syntax
    public sealed class ColorPalette : object, ISerializableAsset, IEnumerable<Color>

    Constructors

    ColorPalette()

    Creates a new Color palette.

    Declaration
    public ColorPalette()

    ColorPalette(BinaryReader)

    Creates a new Color palette from memory.

    Declaration
    public ColorPalette(BinaryReader stream)
    Parameters
    Type Name Description
    BinaryReader stream

    A stream that contains the data of the 256 Color values.

    ColorPalette(Color[])

    Creates a new Color palette from memory.

    Declaration
    public ColorPalette(Color[] colors)
    Parameters
    Type Name Description
    Color[] colors

    A 256 length Color array.

    ColorPalette(Byte[])

    Creates a new Color palette from memory.

    Declaration
    public ColorPalette(byte[] buffer)
    Parameters
    Type Name Description
    Byte[] buffer

    A 768 length array that contains the data of the 256 Color values.

    Fields

    LENGTH

    Declaration
    public const int LENGTH = null
    Field Value
    Type Description
    Int32

    Number of colors.

    SIZE

    Declaration
    public const int SIZE = null
    Field Value
    Type Description
    Int32

    Memory size of the palette.

    Properties

    Item[Int32]

    Gets or sets a Color value in DAC format [0..63].

    Declaration
    public Color this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index

    Index in palette.

    Property Value
    Type Description
    Color

    Returns the Color value.

    Methods

    GetHashCode()

    Generates a hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    Returns an SHA256 hash code from the MD5 hash created by the binary serialized data of this instance.

    Sort()

    Sorts the Color values.

    Declaration
    public void Sort()
    Remarks

    This method try to sort the colors using the Nearest Neighbour algorithm, trying to ensure that the black color (0, 0, 0), if exists in palette, be the first color. This implementation is based on this article: https://www.alanzucconi.com/2015/09/30/colour-sorting/

    ToArray()

    Gets the Color array from this instance.

    Declaration
    public Color[] ToArray()
    Returns
    Type Description
    Color[]

    Returns new Color array of DAC values [0..63].

    Remarks

    Use the ToRGB() function get a full RGB range [0..255] Color array.

    ToRGB()

    Gets a full RGB range values [0..255].

    Declaration
    public Color[] ToRGB()
    Returns
    Type Description
    Color[]

    Returns new Color array of full RGB values [0..255]. In most of the cases, this value is an aproximation to the real RGB value.

    ToString()

    Serializes the relevant data of this instance in a value.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    Returns a value with the relevant serialized data in JSON format.

    Operators

    Equality(ColorPalette, ColorPalette)

    Equality operator.

    Declaration
    public static bool operator ==(ColorPalette a, ColorPalette b)
    Parameters
    Type Name Description
    ColorPalette a

    Left ColorPalette value to compare.

    ColorPalette b

    Right ColorPalette value to compare.

    Returns
    Type Description
    Boolean

    Returns true if both values are equal.

    Inequality(ColorPalette, ColorPalette)

    Inequality operator.

    Declaration
    public static bool operator !=(ColorPalette a, ColorPalette b)
    Parameters
    Type Name Description
    ColorPalette a

    Left ColorPalette value to compare.

    ColorPalette b

    Right ColorPalette value to compare.

    Returns
    Type Description
    Boolean

    Returns true if both values are not equal.

    Implements

    IEnumerable<>
    In This Article
    Back to top
    DIV2.Format.Exporter © Visual Studio EX3, José Miguel Sánchez Fernández - 2020 - 2022 | Site generated with DocFX