Kleidos API Search

In development. It changes without notice.

Topic

Brand Logos

The drawing of a service's logo, at the size a screen has for it.

A logo is decoded row by row, tinted, dithered for a panel of two tones, or made smaller in place. Which logo a login has is asked of Brand Lookup & Logo Atlas; a service without one gets a tile with its first letter (Interface Components).

See also
Brand Lookup & Logo Atlas, Interface Components

Files

file src/ui/brands/brand_bitmap.h
Brand-logo bitmap decoding helpers (RLE decode + RGB565 expansion).
file src/ui/brands/brand_renderer.h
The direct-HAL brand-logo renderer: drawBrand() and its options.

Classes

struct kleidos::ui::brands::bitmap::DecodeResult
Result of decodeRle(): status plus bytes consumed and produced. More about kleidos::ui::brands::bitmap::DecodeResult
struct kleidos::ui::brands::bitmap::AtlasSource
Raw atlas payload location for a decode call. More about kleidos::ui::brands::bitmap::AtlasSource
struct kleidos::ui::brands::bitmap::TintOptions
Color/tint options applied while expanding an entry to RGB565. More about kleidos::ui::brands::bitmap::TintOptions
struct kleidos::ui::brands::bitmap::ScratchBuffer
Caller-supplied alpha working buffer for a decode call. More about kleidos::ui::brands::bitmap::ScratchBuffer
struct kleidos::ui::brands::bitmap::PixelOutput
Caller-supplied RGB565 destination for a decode call. More about kleidos::ui::brands::bitmap::PixelOutput
struct kleidos::ui::brands::bitmap::CoverageOutput
Caller-supplied per-pixel ink-coverage destination for a gray decode. More about kleidos::ui::brands::bitmap::CoverageOutput
struct kleidos::ui::brands::DrawOptions
Optional draw parameters for drawBrand(). More about kleidos::ui::brands::DrawOptions

Enumerations

enum class kleidos::ui::brands::bitmap::DecodeStatus : uint8_t { kleidos::ui::brands::bitmap::DecodeStatus::Ok , kleidos::ui::brands::bitmap::DecodeStatus::InvalidInput , kleidos::ui::brands::bitmap::DecodeStatus::InputTooShort , kleidos::ui::brands::bitmap::DecodeStatus::OutputTooSmall }
Outcome of an RLE decode pass. More about kleidos::ui::brands::bitmap::DecodeStatus

Functions

constexpr size_tkleidos::ui::brands::bitmap::maskByteCount (uint8_t width, uint8_t height)
Bytes needed for a 1-bpp alpha mask of a width x height bitmap.
constexpr size_tkleidos::ui::brands::bitmap::alphaA4ByteCount (uint8_t width, uint8_t height)
Bytes needed for a 4-bpp (A4) alpha channel of a width x height bitmap.
boolkleidos::ui::brands::bitmap::maskBitIsSet (const uint8_t *mask, size_t pixelIndex)
True when the alpha-mask bit for pixelIndex is set.
DecodeResultkleidos::ui::brands::bitmap::decodeRle (const uint8_t *input, size_t inputLen, uint8_t *output, size_t outputLen)
Decode an RLE payload into output.
boolkleidos::ui::brands::bitmap::decodeEntryToRgb565 (const kleidos::brands::BrandEntry &entry, AtlasSource atlas, TintOptions tint, ScratchBuffer scratch, PixelOutput out)
Decode a brand-atlas entry into RGB565 pixels, applying optional tint and alpha mask.
boolkleidos::ui::brands::bitmap::decodeGray4ToCoverage (const kleidos::brands::BrandEntry &entry, AtlasSource atlas, ScratchBuffer scratch, CoverageOutput out)
Decode a gray4 (2-bpp, 4-tone) brand entry into per-pixel ink coverage.
voidkleidos::ui::brands::bitmap::shrinkSquareNearest (const uint16_t *src, uint8_t srcEdge, uint16_t *dst, uint8_t dstEdge)
Nearest-neighbor downscale a square RGB565 tile.
voidkleidos::ui::brands::bitmap::shrinkCoverageBoxFilter (const uint8_t *src, uint8_t srcEdge, uint8_t *dst, uint8_t dstEdge)
Area-average (box-filter) downscale a square ink-coverage map.
voidkleidos::ui::brands::bitmap::shrinkSquareBoxFilterRgb565 (const uint16_t *src, uint8_t srcEdge, uint16_t *dst, uint8_t dstEdge)
Area-average (box-filter) downscale a square RGB565 tile.
boolkleidos::ui::brands::drawBrand (const char *domainOrService, int16_t x, int16_t y, kleidos::brands::Size size, DrawOptions options={})
Draw the resolved brand logo at (x, y) via the display HAL.
boolkleidos::ui::brands::drawKleidosHeaderMark (int16_t x, int16_t y, uint8_t edge, uint16_t background565)
Draw the anti-aliased Kleidos header key-mark inside an edge square.
boolkleidos::ui::brands::drawKleidosWelcomeMark (int16_t centerX, int16_t centerY, uint8_t edge, uint16_t background565)
Draw the big anti-aliased Kleidos welcome (splash) key-mark.

Back to the top

Enumeration Type Documentation

DecodeStatus #

enum class kleidos::ui::brands::bitmap::DecodeStatus : uint8_t

Outcome of an RLE decode pass.

Enumerator
Ok 

Decode completed; outputs are valid.

InvalidInput 

Null pointers or a malformed header.

InputTooShort 

Encoded stream ended before all pixels were produced.

OutputTooSmall 

Destination buffer cannot hold the decoded pixels.

Back to the top

Function Documentation

alphaA4ByteCount() #

size_t kleidos::ui::brands::bitmap::alphaA4ByteCount(uint8_t width, uint8_t height)
constexpr

Bytes needed for a 4-bpp (A4) alpha channel of a width x height bitmap.

A4 alpha packs two pixels per byte, so it needs more scratch than the 1-bpp mask. Callers that may decode color (A4) assets must size their work buffer to at least this many bytes.

Parameters
NameDirectionMeaning
widthinBitmap width in pixels.
heightinBitmap height in pixels.
Returns
Byte count for the A4 alpha buffer.

decodeEntryToRgb565() #

bool kleidos::ui::brands::bitmap::decodeEntryToRgb565(const kleidos::brands::BrandEntry & entry, AtlasSource atlas, TintOptions tint, ScratchBuffer scratch, PixelOutput out)

Decode a brand-atlas entry into RGB565 pixels, applying optional tint and alpha mask.

Pure data transform; safe to call from any task context. The supplied scratch buffer is the alpha working area; size it to alphaA4ByteCount(width, height) bytes (>= maskByteCount) so it can hold either a color A4 alpha channel or a 1-bpp mono mask.

Parameters
NameDirectionMeaning
entryinAtlas entry describing the bitmap.
atlasinRaw atlas payload (blob pointer + size).
tintinBackground/tint color options.
scratchoutAlpha working buffer (pointer + capacity).
outoutRGB565 destination (pixel pointer + capacity).
Return values
ValueMeaning
trueDecoded successfully; out.pixels is filled with RGB565 data.
falseA pointer was null, sizes mismatched, or decodeRle failed.

decodeGray4ToCoverage() #

bool kleidos::ui::brands::bitmap::decodeGray4ToCoverage(const kleidos::brands::BrandEntry & entry, AtlasSource atlas, ScratchBuffer scratch, CoverageOutput out)

Decode a gray4 (2-bpp, 4-tone) brand entry into per-pixel ink coverage.

The gray4 atlas payload is RLE(pack_bits(levels, 2)): a big-endian bitstream of 2-bit ladder indices (0 = white paper .. 3 = black ink), row-major, one per pixel. This decodes the RLE, unpacks each 2-bit level, and maps it to an 8-bit ink coverage (0, 85, 170, 255) that a monochrome panel can ordered-dither into an ink/paper stipple (see kleidos::hal::display::monoBayerInk). Pure data transform; safe to call from any task context. The scratch buffer holds the unpacked 2-bpp bytes; size it to at least (width*height + 3) / 4 bytes.

Parameters
NameDirectionMeaning
entryinAtlas entry describing the bitmap (must be a gray4 entry).
atlasinRaw atlas payload (blob pointer + size).
scratchoutPacked-bitstream working buffer (pointer + capacity).
outoutInk-coverage destination (pointer + capacity in pixels).
Return values
ValueMeaning
trueDecoded successfully; out.coverage holds 0..255 coverage.
falseA pointer was null, sizes mismatched, the entry is not gray4, or decodeRle failed.

decodeRle() #

DecodeResult kleidos::ui::brands::bitmap::decodeRle(const uint8_t * input, size_t inputLen, uint8_t * output, size_t outputLen)

Decode an RLE payload into output.

RLE format: a stream of control bytes; bit 7 selects run (0 = literal, 1 = repeat), bits 0..6 hold (length - 1). Pure data transform; safe to call from any task context.

Parameters
NameDirectionMeaning
inputinPointer to the encoded payload.
inputLeninLength of the encoded payload in bytes.
outputoutDestination buffer for decoded bytes.
outputLeninCapacity of output in bytes.
Return values
ValueMeaning
DecodeStatus::OkDecode completed; bytesRead and bytesWritten are valid.
DecodeStatus::InvalidInputNull pointer with non-zero size.
DecodeStatus::InputTooShortEncoded stream ended early.
DecodeStatus::OutputTooSmallDestination cannot hold the decoded bytes.

drawBrand() #

bool kleidos::ui::brands::drawBrand(const char * domainOrService, int16_t x, int16_t y, kleidos::brands::Size size, DrawOptions options = {})

Draw the resolved brand logo at (x, y) via the display HAL.

Parameters
NameDirectionMeaning
domainOrServiceinDomain or service name to look up.
xinTop-left X coordinate on the display.
yinTop-left Y coordinate on the display.
sizeinRequested logical size.
optionsinDraw-time options (foreground color, fit box, etc.).
Return values
ValueMeaning
trueBrand was found and drawn at (x, y).
falseNo entry matched; nothing was drawn.
Note
When options.fitEdge is non-zero and smaller than the resolved asset, the logo is nearest-neighbor downscaled to a fitEdge square so a small badge can show a logo from a larger-only atlas without clipping.

drawKleidosHeaderMark() #

bool kleidos::ui::brands::drawKleidosHeaderMark(int16_t x, int16_t y, uint8_t edge, uint16_t background565)

Draw the anti-aliased Kleidos header key-mark inside an edge square.

Decodes the AA color mark asset (see KleidosMarkGenerated) nearest edge and blits it via the display HAL, centered when the chosen native asset is smaller than edge. Color boards only: on a mono / e-paper board no mark table is compiled and this returns false so the caller draws the primitive fallback.

Parameters
NameDirectionMeaning
xinTop-left X of the reserved square.
yinTop-left Y of the reserved square.
edgeinReserved square edge length in pixels.
background565inFill behind transparent pixels (the header surface).
Return values
ValueMeaning
trueA mark asset was decoded and drawn.
falseNo mark table is compiled, or decoding failed.

drawKleidosWelcomeMark() #

bool kleidos::ui::brands::drawKleidosWelcomeMark(int16_t centerX, int16_t centerY, uint8_t edge, uint16_t background565)

Draw the big anti-aliased Kleidos welcome (splash) key-mark.

Decodes the AA color welcome-mark asset (see KleidosWelcomeMarkGenerated) nearest edge and blits it via the display HAL, centered on (centerX, centerY). Unlike the small header mark, the welcome mark can reach 128 px, so its decode buffers come from the PSRAM-aware large-allocation facade (kleidos::platform::memory, memory.h) and are freed immediately after the one-shot splash blit. Color boards only: on a mono / e-paper board no welcome table is compiled (and edge would be huge), so this returns false and the caller draws the primitive fallback.

Parameters
NameDirectionMeaning
centerXinCenter X of the mark in pixels.
centerYinCenter Y of the mark in pixels.
edgeinDesired mark edge length in pixels (target box side).
background565inFill behind transparent pixels (the screen background).
Return values
ValueMeaning
trueA welcome-mark asset was decoded and drawn.
falseNo welcome table is compiled, the allocation failed, or decoding failed.

maskBitIsSet() #

bool kleidos::ui::brands::bitmap::maskBitIsSet(const uint8_t * mask, size_t pixelIndex)

True when the alpha-mask bit for pixelIndex is set.

Parameters
NameDirectionMeaning
maskinPointer to the alpha mask byte array.
pixelIndexinZero-based pixel index.
Return values
ValueMeaning
trueCorresponding bit in the mask is 1.
falseCorresponding bit is 0.

maskByteCount() #

size_t kleidos::ui::brands::bitmap::maskByteCount(uint8_t width, uint8_t height)
constexpr

Bytes needed for a 1-bpp alpha mask of a width x height bitmap.

Parameters
NameDirectionMeaning
widthinBitmap width in pixels.
heightinBitmap height in pixels.
Returns
Byte count for the mask buffer.

shrinkCoverageBoxFilter() #

void kleidos::ui::brands::bitmap::shrinkCoverageBoxFilter(const uint8_t * src, uint8_t srcEdge, uint8_t * dst, uint8_t dstEdge)

Area-average (box-filter) downscale a square ink-coverage map.

Each destination pixel is the rounded mean of the source box that maps onto it. Averaging the continuous tone BEFORE an ordered dither keeps the gray levels intact, where nearest-neighbor would sample a single pixel and wreck a stipple that has not been laid down yet.

dst may be src. Every source pixel a destination pixel averages lies at or after the destination's own index, so the map can be shrunk where it lies. A dstEdge of 0 or larger than srcEdge writes nothing.

Parameters
NameDirectionMeaning
srcinSource coverage, srcEdge x srcEdge, row-major.
srcEdgeinSource side in pixels.
dstoutDestination, at least dstEdge x dstEdge bytes; may be src.
dstEdgeinDestination side in pixels, at most srcEdge.

shrinkSquareBoxFilterRgb565() #

void kleidos::ui::brands::bitmap::shrinkSquareBoxFilterRgb565(const uint16_t * src, uint8_t srcEdge, uint16_t * dst, uint8_t dstEdge)

Area-average (box-filter) downscale a square RGB565 tile.

Each destination pixel is the per-channel rounded mean of the source box that maps onto it. The source was alpha-composited against its background during decode, so averaging the composited colors rebuilds the coverage gradient an anti-aliased downsample would give: a scaled-down mark keeps smooth edges where shrinkSquareNearest() would stair-step them.

dst may be src, for the same reason as in shrinkCoverageBoxFilter(). A dstEdge of 0 or larger than srcEdge writes nothing.

Parameters
NameDirectionMeaning
srcinSource pixels, srcEdge x srcEdge, row-major.
srcEdgeinSource side in pixels.
dstoutDestination, at least dstEdge x dstEdge pixels; may be src.
dstEdgeinDestination side in pixels, at most srcEdge.

shrinkSquareNearest() #

void kleidos::ui::brands::bitmap::shrinkSquareNearest(const uint16_t * src, uint8_t srcEdge, uint16_t * dst, uint8_t dstEdge)

Nearest-neighbor downscale a square RGB565 tile.

Shrinks the srcEdge square at src into the dstEdge square at dst, sampling one source pixel per destination pixel. Crisp, but it drops the atlas's anti-aliased A4 edge gradient, so curves go jaggy: use it only where the asset is already low-contrast or the edge does not matter.

dst may be src. Every destination pixel reads one source pixel at or after its own index, and the pixels before it are all that has been written, so a decoded tile can be shrunk where it lies without a second tile-sized buffer. A dstEdge of 0 or larger than srcEdge writes nothing.

Parameters
NameDirectionMeaning
srcinSource pixels, srcEdge x srcEdge, row-major.
srcEdgeinSource side in pixels.
dstoutDestination, at least dstEdge x dstEdge pixels; may be src.
dstEdgeinDestination side in pixels, at most srcEdge.

Back to the top