xtap-core-lib 0.5.1

星TAP实验室通用 Rust 基座:跨平台路径/IO/硬件/MCP HTTP 服务/egui 主题与字体(features 按需裁剪)
Documentation
use crate::ui::theme::UiTheme;

pub struct IconMaster;

impl IconMaster {
    pub const ICON_SETTINGS: &'static str = "\u{f101}";
    pub const ICON_USER: &'static str = "\u{f102}";
    pub const ICON_SEARCH: &'static str = "\u{f103}";

    pub fn get_icon_size() -> f32 {
        UiTheme::ICON_SIZE
    }
}

/// Load an egui IconData from raw image bytes (jpg/png/webp/etc).
/// The caller typically provides `include_bytes!("path/to/icon.png")`.
pub fn load_egui_icon_from_bytes(bytes: &[u8]) -> egui::IconData {
    let img = image::load_from_memory(bytes).expect("Failed to decode icon image");
    let rgba = img.to_rgba8();
    let (w, h) = rgba.dimensions();
    egui::IconData {
        rgba: rgba.into_raw(),
        width: w,
        height: h,
    }
}