fix: 缩放的屏幕,灯条颜色预览效果错误

This commit is contained in:
2023-03-26 15:54:57 +08:00
parent 1a3102257e
commit 3e54d30498
4 changed files with 24 additions and 31 deletions

View File

@ -98,24 +98,19 @@ async fn write_led_strip_configs(
async fn get_led_strips_sample_points(
config: LedStripConfig,
) -> Result<Vec<screenshot::LedSamplePoints>, String> {
let displays = DisplayInfo::all().map_err(|e| {
error!("can not read led strip config: {}", e);
e.to_string()
});
let display = displays?.into_iter().find(|d| d.id == config.display_id);
if let None = display {
let screenshot_manager = ScreenshotManager::global().await;
let channels = screenshot_manager.channels.read().await;
if let Some(rx) = channels.get(&config.display_id) {
let rx = rx.clone();
let screenshot = rx.borrow().clone();
let width = screenshot.width;
let height = screenshot.height;
let sample_points =
Screenshot::get_sample_point(&config, width as usize, height as usize);
Ok(sample_points)
} else {
return Err(format!("display not found: {}", config.display_id));
}
let display = display.unwrap();
let config = screenshot::Screenshot::get_sample_point(
config,
display.width as usize,
display.height as usize,
);
Ok(config)
}
#[tauri::command]

View File

@ -42,7 +42,7 @@ impl Screenshot {
}
pub fn get_sample_point(
config: LedStripConfig,
config: &LedStripConfig,
width: usize,
height: usize,
) -> Vec<LedSamplePoints> {