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).
Files | |
| file | src/ |
| Brand-logo bitmap decoding helpers (RLE decode + RGB565 expansion). | |
| file | src/ |
The direct-HAL brand-logo renderer: drawBrand() and its options. | |
Enumerations | |
| enum class | kleidos:: |
| Outcome of an RLE decode pass. More about kleidos:: | |
Functions | |
| constexpr size_t | kleidos:: |
Bytes needed for a 1-bpp alpha mask of a width x height bitmap. | |
| constexpr size_t | kleidos:: |
Bytes needed for a 4-bpp (A4) alpha channel of a width x height bitmap. | |
| bool | kleidos:: |
True when the alpha-mask bit for pixelIndex is set. | |
| DecodeResult | kleidos:: |
Decode an RLE payload into output. | |
| bool | kleidos:: |
| Decode a brand-atlas entry into RGB565 pixels, applying optional tint and alpha mask. | |
| bool | kleidos:: |
| Decode a gray4 (2-bpp, 4-tone) brand entry into per-pixel ink coverage. | |
| void | kleidos:: |
| Nearest-neighbor downscale a square RGB565 tile. | |
| void | kleidos:: |
| Area-average (box-filter) downscale a square ink-coverage map. | |
| void | kleidos:: |
| Area-average (box-filter) downscale a square RGB565 tile. | |
| bool | kleidos:: |
Draw the resolved brand logo at (x, y) via the display HAL. | |
| bool | kleidos:: |
Draw the anti-aliased Kleidos header key-mark inside an edge square. | |
| bool | kleidos:: |
| Draw the big anti-aliased Kleidos welcome (splash) key-mark. | |
Enumeration Type Documentation
DecodeStatus #
Function Documentation
alphaA4ByteCount() #
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
-
Name Direction Meaning width in Bitmap width in pixels. height in Bitmap height in pixels.
- Returns
- Byte count for the A4 alpha buffer.
decodeEntryToRgb565() #
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
-
Name Direction Meaning entry in Atlas entry describing the bitmap. atlas in Raw atlas payload (blob pointer + size). tint in Background/ tint color options. scratch out Alpha working buffer (pointer + capacity). out out RGB565 destination (pixel pointer + capacity).
- Return values
-
Value Meaning true Decoded successfully; out.pixelsis filled with RGB565 data.false A pointer was null, sizes mismatched, or decodeRlefailed.
decodeGray4ToCoverage() #
Decode a gray4 (2-bpp, 4-tone) brand entry into per-pixel ink coverage.
The gray4 atlas payload is RLE(pack_: 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::scratch buffer holds the unpacked 2-bpp bytes; size it to at least (width*height + 3) / 4 bytes.
- Parameters
-
Name Direction Meaning entry in Atlas entry describing the bitmap (must be a gray4 entry). atlas in Raw atlas payload (blob pointer + size). scratch out Packed-bitstream working buffer (pointer + capacity). out out Ink-coverage destination (pointer + capacity in pixels).
- Return values
-
Value Meaning true Decoded successfully; out.coverageholds 0..255 coverage.false A pointer was null, sizes mismatched, the entry is not gray4, or decodeRlefailed.
decodeRle() #
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
-
Name Direction Meaning input in Pointer to the encoded payload. inputLen in Length of the encoded payload in bytes. output out Destination buffer for decoded bytes. outputLen in Capacity of outputin bytes.
- Return values
-
Value Meaning DecodeStatus:: Ok Decode completed; bytesReadandbytesWrittenare valid.DecodeStatus:: InvalidInput Null pointer with non-zero size. DecodeStatus:: InputTooShort Encoded stream ended early. DecodeStatus:: OutputTooSmall Destination cannot hold the decoded bytes.
drawBrand() #
Draw the resolved brand logo at (x, y) via the display HAL.
- Parameters
-
Name Direction Meaning domainOrService in Domain or service name to look up. x in Top-left X coordinate on the display. y in Top-left Y coordinate on the display. size in Requested logical size. options in Draw-time options (foreground color, fit box, etc.).
- Return values
-
Value Meaning true Brand was found and drawn at ( x,y).false No entry matched; nothing was drawn.
- Note
- When
options.fitEdgeis non-zero and smaller than the resolved asset, the logo is nearest-neighbor downscaled to afitEdgesquare so a small badge can show a logo from a larger-only atlas without clipping.
drawKleidosHeaderMark() #
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
-
Name Direction Meaning x in Top-left X of the reserved square. y in Top-left Y of the reserved square. edge in Reserved square edge length in pixels. background565 in Fill behind transparent pixels (the header surface).
- Return values
-
Value Meaning true A mark asset was decoded and drawn. false No mark table is compiled, or decoding failed.
drawKleidosWelcomeMark() #
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::, 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
-
Name Direction Meaning centerX in Center X of the mark in pixels. centerY in Center Y of the mark in pixels. edge in Desired mark edge length in pixels (target box side). background565 in Fill behind transparent pixels (the screen background).
- Return values
-
Value Meaning true A welcome-mark asset was decoded and drawn. false No welcome table is compiled, the allocation failed, or decoding failed.
maskBitIsSet() #
True when the alpha-mask bit for pixelIndex is set.
- Parameters
-
Name Direction Meaning mask in Pointer to the alpha mask byte array. pixelIndex in Zero-based pixel index.
- Return values
-
Value Meaning true Corresponding bit in the mask is 1. false Corresponding bit is 0.
maskByteCount() #
Bytes needed for a 1-bpp alpha mask of a width x height bitmap.
- Parameters
-
Name Direction Meaning width in Bitmap width in pixels. height in Bitmap height in pixels.
- Returns
- Byte count for the mask buffer.
shrinkCoverageBoxFilter() #
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
-
Name Direction Meaning src in Source coverage, srcEdgexsrcEdge, row-major.srcEdge in Source side in pixels. dst out Destination, at least dstEdgexdstEdgebytes; may besrc.dstEdge in Destination side in pixels, at most srcEdge.
shrinkSquareBoxFilterRgb565() #
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
-
Name Direction Meaning src in Source pixels, srcEdgexsrcEdge, row-major.srcEdge in Source side in pixels. dst out Destination, at least dstEdgexdstEdgepixels; may besrc.dstEdge in Destination side in pixels, at most srcEdge.
shrinkSquareNearest() #
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
-
Name Direction Meaning src in Source pixels, srcEdgexsrcEdge, row-major.srcEdge in Source side in pixels. dst out Destination, at least dstEdgexdstEdgepixels; may besrc.dstEdge in Destination side in pixels, at most srcEdge.