Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down