Commit d03d65fd authored by René Rössler's avatar René Rössler 😍
Browse files

always set colors for all measurement points

so that switching in beetween them doesn't show wrong/missing colors.
parent 55ff5e45
Pipeline #103240488 passed with stage
in 11 minutes and 3 seconds
......@@ -130,7 +130,6 @@ fn animate(
/// Iterate over all measurement points in currently selected render group and read its color from the given image
fn get_colors(
config: &Arc<RwLock<RendererConfig>>,
image_live: &mut Image,
measurement_points: &MeasurementPoints,
) -> Option<()> {
......@@ -141,25 +140,26 @@ fn get_colors(
let data = image_live.data.as_ref()?;
let stride = image_live.stride();
let mut measurement_points = measurement_points.write().unwrap();
let config = config.read().unwrap();
let measurement_points = measurement_points.as_mut()?;
let active_render_group = config.active_render_group.as_ref()?;
let active_measurement_points = measurement_points.get_mut(active_render_group)?;
active_measurement_points
.iter_mut()
.for_each(|mut measurement_point| {
let point = measurement_point.point;
let pos = ((point.y as i32) * stride + 4 * point.x as i32) as usize;
if pos < data.len() {
let blue = (f64::from(data[pos]) * master_dimmer).round() as u8;
let green = (f64::from(data[pos + 1]) * master_dimmer).round() as u8;
let red = (f64::from(data[pos + 2]) * master_dimmer).round() as u8;
measurement_point.color = Color { red, green, blue };
} else {
warn!("out of range: {}/{}", pos, data.len());
}
measurement_points
.write()
.unwrap()
.as_mut()?
.values_mut()
.for_each(|measurement_points| {
measurement_points
.iter_mut()
.for_each(|mut measurement_point| {
let point = measurement_point.point;
let pos = ((point.y as i32) * stride + 4 * point.x as i32) as usize;
if pos < data.len() {
let blue = (f64::from(data[pos]) * master_dimmer).round() as u8;
let green = (f64::from(data[pos + 1]) * master_dimmer).round() as u8;
let red = (f64::from(data[pos + 2]) * master_dimmer).round() as u8;
measurement_point.color = Color { red, green, blue };
} else {
warn!("out of range: {}/{}", pos, data.len());
}
})
});
None
}
......@@ -231,7 +231,7 @@ pub fn spawn(renderer: &Renderer) {
}
let (elapsed, _) = measure_time(|| {
get_colors(&config, image_live, &measurement_points);
get_colors(image_live, &measurement_points);
});
debug!("Get Colors: {:?}", elapsed);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment