From 125c0673f30511f36d33bd0784576793ea1fbfc0 Mon Sep 17 00:00:00 2001 From: Kris Giesing Date: Wed, 2 Mar 2016 16:20:28 -0800 Subject: [PATCH] Use bilinear interpolation when scaling images Fixes #2337 --- packages/flutter/lib/src/painting/box_painter.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/flutter/lib/src/painting/box_painter.dart b/packages/flutter/lib/src/painting/box_painter.dart index 9f5cf286857..7155dba27df 100644 --- a/packages/flutter/lib/src/painting/box_painter.dart +++ b/packages/flutter/lib/src/painting/box_painter.dart @@ -528,6 +528,12 @@ void paintImage({ Paint paint = new Paint()..isAntiAlias = false; if (colorFilter != null) 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 dy = (outputSize.height - destinationSize.height) * (alignY ?? 0.5); Point destinationPosition = rect.topLeft + new Offset(dx, dy);