feat: user uploaded icons can use templates, provided they are monochrome icons fixer #2213

This commit is contained in:
huzibaca
2024-11-30 09:49:43 +08:00
parent 0eb5ee6ea8
commit 50285aebde
4 changed files with 349 additions and 28 deletions

View File

@@ -103,6 +103,19 @@ pub fn open_file(_: tauri::AppHandle, path: PathBuf) -> Result<()> {
Ok(())
}
// 添加新的函数来处理字节数据
pub fn is_monochrome_image_from_bytes(data: &[u8]) -> anyhow::Result<bool> {
let img = image::load_from_memory(data)?;
let rgb_img = img.to_rgb8();
for pixel in rgb_img.pixels() {
if pixel[0] != pixel[1] || pixel[1] != pixel[2] {
return Ok(false);
}
}
Ok(true)
}
#[cfg(target_os = "linux")]
pub fn linux_elevator() -> String {
use std::process::Command;