Commit 125c0673 authored by Kris Giesing's avatar Kris Giesing

Use bilinear interpolation when scaling images

Fixes #2337
parent 7a2d82d0
...@@ -528,6 +528,12 @@ void paintImage({ ...@@ -528,6 +528,12 @@ void paintImage({
Paint paint = new Paint()..isAntiAlias = false; Paint paint = new Paint()..isAntiAlias = false;
if (colorFilter != null) if (colorFilter != null)
paint.colorFilter = colorFilter; paint.colorFilter = colorFilter;
if (sourceSize != destinationSize) {
// Use the "low" quality setting to scale the image, which corresponds to
// bilinear interpolation, rather than the default "none" which corresponds
// to nearest-neighbor.
paint.filterQuality = FilterQuality.low;
}
double dx = (outputSize.width - destinationSize.width) * (alignX ?? 0.5); double dx = (outputSize.width - destinationSize.width) * (alignX ?? 0.5);
double dy = (outputSize.height - destinationSize.height) * (alignY ?? 0.5); double dy = (outputSize.height - destinationSize.height) * (alignY ?? 0.5);
Point destinationPosition = rect.topLeft + new Offset(dx, dy); Point destinationPosition = rect.topLeft + new Offset(dx, dy);
......
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