| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef __TITLE_H__
- #define __TITLE_H__
- #include <stdint.h>
- typedef struct {
- int enable;
- int type; /* 0 = bar (solid, reserves space), 1 = overlay (translucent) */
- int height; /* bar height, rounded down to even */
- char text[256];
- char logo[256];
- char font[256];
- int font_size;
- unsigned color; /* RGB, e.g. 0xFFFFFF = white */
- int logo_pad;
- int opacity; /* logo/text global opacity 0-255, 255 = opaque */
- } TitleCfg;
- /* Render the title bar (logo + text) into the top of an NV12 buffer.
- * map must point to out_w*out_h*3/2 bytes. Returns 0 on success, -1 on error. */
- int title_render(uint8_t *map, int out_w, int out_h, const TitleCfg *cfg);
- /* Return the first available default font path (WQY microhei, else zenhei). */
- const char *title_default_font(void);
- /* Render a translucent title strip over existing frame content (overlay mode):
- * darkens the top cfg->height rows, then draws logo + text on top. The video
- * below/under it is left intact. Returns 0 on success, -1 on error. */
- int title_render_overlay(uint8_t *map, int out_w, int out_h, const TitleCfg *cfg);
- /* Render one text line centered on (center_x, center_y) into the NV12 buffer.
- * center_x <= 0 centers over the whole width; center_y <= 0 uses out_h/2.
- * Font falls back to the WQY micro hei path if empty. Returns 0 on success. */
- int title_render_text(uint8_t *map, int out_w, int out_h,
- const char *font, const char *text, int size,
- unsigned color, int center_x, int center_y);
- /* Advance width (px) of a UTF-8 text line, or -1 on error.
- * Empty font falls back to the WQY default. Used for right-aligned text. */
- long title_measure_text(const char *font, const char *text, int size);
- /* Draw a small translucent PLC connection status badge in the top-right
- * corner of an NV12 buffer: colored dot (green = connected, red = offline)
- * plus a label. Returns 0 on success, -1 on error. */
- int title_render_plc_status(uint8_t *map, int out_w, int out_h,
- const char *font, int connected);
- /* Draw a translucent pill in the bottom-left corner showing the given text
- * (used for the board's IP address(es)) so the operator can read it on screen.
- * Returns 0 on success, -1 on error. */
- int title_render_ip(uint8_t *map, int out_w, int out_h,
- const char *font, const char *text);
- #endif
|