diff --git a/src/images.rs b/src/images.rs index 0215030..adfd31a 100644 --- a/src/images.rs +++ b/src/images.rs @@ -26,7 +26,19 @@ pub fn convert_image_with_format(image_format: ImageFormat, image: DynamicImage) ImageRotation::Rot270 => image.rotate270(), }; - let image = image.resize_exact(ws as u32, hs as u32, FilterType::Nearest); + // Nearest-neighbour discards the antialiasing of whatever the caller drew. At the + // Stream Deck +'s 6:5 ratio (144 -> 120) it drops every sixth row and column and + // point-samples soft edges into stair-steps. + // + // Cost scales with the source area, which is up to the caller, so skip the resample + // altogether when the image already matches the format. That is both the common case + // and the escape hatch: a caller that scales to the target size itself pays nothing + // here, rather than paying for a resample to get its own pixels back. + let image = if image.dimensions() == (ws as u32, hs as u32) { + image + } else { + image.resize_exact(ws as u32, hs as u32, FilterType::Lanczos3) + }; // Applying mirroring let image = match image_format.mirror {