bn::bg_palette_item class

Contains the required information to generate background color palettes.

The assets conversion tools generate an object of this type in the build folder for each *.bmp file with regular_bg or affine_bg types.

The colors are not copied but referenced, so they should outlive the bg_palette_item to avoid dangling references.

Constructors, destructors, conversion operators

bg_palette_item(const span<const color>& colors_ref, bpp_mode bpp) constexpr
Constructor.
bg_palette_item(const span<const color>& colors_ref, bpp_mode bpp, compression_type compression) constexpr
Constructor.

Public functions

auto colors_ref() const -> const span<const color>& constexpr
Returns the referenced array of multiples of 16 colors.
auto bpp() const -> bpp_mode constexpr
Returns the bits per pixel of the color palettes to create.
auto compression() const -> compression_type constexpr
Returns the compression type.
auto decompress(span<color> decompressed_colors_ref) const -> bg_palette_item
Decompresses the stored data in the colors referenced by decompressed_colors_ref.
auto find_palette() const -> optional<bg_palette_ptr>
Searches for a bg_palette_ptr which contains the colors referenced by this item.
auto create_palette() const -> bg_palette_ptr
Searches for a bg_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a bg_palette_ptr which contains them.
auto create_new_palette() const -> bg_palette_ptr
Creates a new bg_palette_ptr which contains the colors referenced by this item.
auto create_palette_optional() const -> optional<bg_palette_ptr>
Searches for a bg_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a bg_palette_ptr which contains them.
auto create_new_palette_optional() const -> optional<bg_palette_ptr>
Creates a new bg_palette_ptr which contains the colors referenced by this item.

Friends

auto operator==(const bg_palette_item& a, const bg_palette_item& b) -> bool defaulted constexpr
Default equal operator.

Function documentation

bn::bg_palette_item::bg_palette_item(const span<const color>& colors_ref, bpp_mode bpp) constexpr

Constructor.

Parameters
colors_ref Reference to an array of multiples of 16 colors.
bpp Bits per pixel of the color palettes to create.

The colors are not copied but referenced, so they should outlive the bg_palette_item to avoid dangling references.

bn::bg_palette_item::bg_palette_item(const span<const color>& colors_ref, bpp_mode bpp, compression_type compression) constexpr

Constructor.

Parameters
colors_ref Reference to an array of multiples of 16 colors.
bpp Bits per pixel of the color palettes to create.
compression Compression type.

The colors are not copied but referenced, so they should outlive the bg_palette_item to avoid dangling references.

const span<const color>& bn::bg_palette_item::colors_ref() const constexpr

Returns the referenced array of multiples of 16 colors.

The colors are not copied but referenced, so they should outlive the bg_palette_item to avoid dangling references.

bg_palette_item bn::bg_palette_item::decompress(span<color> decompressed_colors_ref) const

Decompresses the stored data in the colors referenced by decompressed_colors_ref.

Parameters
decompressed_colors_ref Destination of the decompressed colors.
Returns A bg_palette_item pointing to the decompressed colors.

If the source and destination colors overlap, the behavior is undefined.

optional<bg_palette_ptr> bn::bg_palette_item::find_palette() const

Searches for a bg_palette_ptr which contains the colors referenced by this item.

Returns bg_palette_ptr which contains the colors referenced by this item if it has been found; bn::nullopt otherwise.

bg_palette_ptr bn::bg_palette_item::create_palette() const

Searches for a bg_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a bg_palette_ptr which contains them.

Returns bg_palette_ptr which contains the colors referenced by this item if it has been found; otherwise it returns a new bg_palette_ptr which contains them.

bg_palette_ptr bn::bg_palette_item::create_new_palette() const

Creates a new bg_palette_ptr which contains the colors referenced by this item.

Returns bg_palette_ptr which contains the colors referenced by this item.

optional<bg_palette_ptr> bn::bg_palette_item::create_palette_optional() const

Searches for a bg_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a bg_palette_ptr which contains them.

Returns bg_palette_ptr which contains the colors referenced by this item if it has been found; otherwise it returns a new bg_palette_ptr which contains them it if it could be allocated; bn::nullopt otherwise.

optional<bg_palette_ptr> bn::bg_palette_item::create_new_palette_optional() const

Creates a new bg_palette_ptr which contains the colors referenced by this item.

Returns bg_palette_ptr which contains the colors referenced by this item it if it could be allocated; bn::nullopt otherwise.