bn::sprite_palette_item class

Contains the required information to generate sprite color palettes.

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

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

Constructors, destructors, conversion operators

sprite_palette_item(const span<const color>& colors_ref, bpp_mode bpp) constexpr
Constructor.
sprite_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 uncompress(span<color> uncompressed_colors_ref) const -> sprite_palette_item
Uncompresses the stored data in the colors referenced by uncompressed_colors_ref.
auto find_palette() const -> optional<sprite_palette_ptr>
Searches for a sprite_palette_ptr which contains the colors referenced by this item.
auto create_palette() const -> sprite_palette_ptr
Searches for a sprite_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a sprite_palette_ptr which contains them.
auto create_new_palette() const -> sprite_palette_ptr
Creates a new sprite_palette_ptr which contains the colors referenced by this item.
auto create_palette_optional() const -> optional<sprite_palette_ptr>
Searches for a sprite_palette_ptr which contains the colors referenced by this item. If it is not found, it creates a sprite_palette_ptr which contains them.
auto create_new_palette_optional() const -> optional<sprite_palette_ptr>
Creates a new sprite_palette_ptr which contains the colors referenced by this item.

Friends

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

Function documentation

bn::sprite_palette_item::sprite_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 sprite_palette_item to avoid dangling references.

bn::sprite_palette_item::sprite_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 sprite_palette_item to avoid dangling references.

const span<const color>& bn::sprite_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 sprite_palette_item to avoid dangling references.

sprite_palette_item bn::sprite_palette_item::uncompress(span<color> uncompressed_colors_ref) const

Uncompresses the stored data in the colors referenced by uncompressed_colors_ref.

Parameters
uncompressed_colors_ref Destination of the uncompressed colors.
Returns A sprite_palette_item pointing to the uncompressed colors.

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

optional<sprite_palette_ptr> bn::sprite_palette_item::find_palette() const

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

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

sprite_palette_ptr bn::sprite_palette_item::create_palette() const

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

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

sprite_palette_ptr bn::sprite_palette_item::create_new_palette() const

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

Returns sprite_palette_ptr which contains the colors referenced by this item.

optional<sprite_palette_ptr> bn::sprite_palette_item::create_palette_optional() const

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

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

optional<sprite_palette_ptr> bn::sprite_palette_item::create_new_palette_optional() const

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

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