Search documentation of wx

# View Source wxPalette (wx v2.4.3)

A palette is a table that maps pixel values to RGB colours.

It allows the colours of a low-depth bitmap, for example, to be mapped to the available colours in a display. The notion of palettes is becoming more and more obsolete nowadays and only the MSW port is still using a native palette. All other ports use generic code which is basically just an array of colours.

It is likely that in the future the only use for palettes within wxWidgets will be for representing colour indices from images (such as GIF or PNG). The image handlers for these formats have been modified to create a palette if there is such information in the original image file (usually 256 or less colour images). See `wxImage` for more information.

Predefined objects (include wx.hrl): ?wxNullPalette

See:

- `wxDC:setPalette/2`

- `wxBitmap`

wxWidgets docs: wxPalette

# Summary

## Types

wxPalette()

## Functions

create(This, Red, Green, Blue)

Creates a palette from arrays of size `n`, one for each red, blue or green component.

destroy(This)

Destroys the object

getColoursCount(This)

Returns number of entries in palette.

getPixel(This, Red, Green, Blue)

Returns a pixel value (index into the palette) for the given RGB values.

getRGB(This, Pixel)

Returns RGB values for a given palette index.

isOk(This)

Returns true if palette data is present.

new()

Default constructor.

new(Palette)

Copy constructor, uses overview_refcount.

new(Red, Green, Blue)

Creates a palette from arrays of size `n`, one for each red, blue or green component.

ok(This)

Equivalent to: `isOk/1`

# Types

Link to this type

# wxPalette()

View Source

    -type wxPalette() :: wx:wx_object().

# Functions

Link to this function

# create(This, Red, Green, Blue)

View Source

    -spec create(This, Red, Green, Blue) -> boolean()
                    when This :: wxPalette(), Red :: binary(), Green :: binary(), Blue :: binary().

Creates a palette from arrays of size `n`, one for each red, blue or green component.

Return: true if the creation was successful, false otherwise.

See: `new/3`

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxPalette()) -> ok.

Destroys the object

Link to this function

# getColoursCount(This)

View Source

    -spec getColoursCount(This) -> integer() when This :: wxPalette().

Returns number of entries in palette.

Link to this function

# getPixel(This, Red, Green, Blue)

View Source

    -spec getPixel(This, Red, Green, Blue) -> integer()
                      when This :: wxPalette(), Red :: integer(), Green :: integer(), Blue :: integer().

Returns a pixel value (index into the palette) for the given RGB values.

Return: The nearest palette index or `wxNOT_FOUND` for unexpected errors.

See: `getRGB/2`

Link to this function

# getRGB(This, Pixel)

View Source

    -spec getRGB(This, Pixel) -> Result
                    when
                        Result ::
                            {Res :: boolean(), Red :: integer(), Green :: integer(), Blue :: integer()},
                        This :: wxPalette(),
                        Pixel :: integer().

Returns RGB values for a given palette index.

Return: true if the operation was successful.

See: `getPixel/4`

Link to this function

# isOk(This)

View Source

    -spec isOk(This) -> boolean() when This :: wxPalette().

Returns true if palette data is present.

Link to this function

# new()

View Source

    -spec new() -> wxPalette().

Default constructor.

Link to this function

# new(Palette)

View Source

    -spec new(Palette) -> wxPalette() when Palette :: wxPalette().

Copy constructor, uses overview_refcount.

Link to this function

# new(Red, Green, Blue)

View Source

    -spec new(Red, Green, Blue) -> wxPalette() when Red :: binary(), Green :: binary(), Blue :: binary().

Creates a palette from arrays of size `n`, one for each red, blue or green component.

See: `create/4`

Link to this function

# ok(This)

View Source

    -spec ok(This) -> boolean() when This :: wxPalette().

Equivalent to: `isOk/1`