2

I have pixel-art style images stored in res/drawable with their naturally small scale, but meant to be scaled up for display. However the default behaviour seems to be to blur the upscaled image to try and hide the pixels. How can that be disabled?

  1. This is from a screenshot of the phone. You can see the image is blurry compared to the text.

blurry image

  1. This is the desired scaled image with sharp pixels (please ignore the background)

desirable image

I see there is a similar question for the old Android framework, but I'm using Jetpack Compose.

Victor Basso
  • 5,556
  • 5
  • 42
  • 60

1 Answers1

2

There is now a a filterQuality parameter you can set to None in the Image composable to disable bilinear interpolation. This is since version 1.1.0-alpha01 of androidx.compose.ui:ui.

Example usage:

Image(
    bitmap = ImageBitmap.imageResource(id = imageId),
    contentDescription = null,
    filterQuality = FilterQuality.None
)

Workarounds for older versions are mentioned here.

Victor Basso
  • 5,556
  • 5
  • 42
  • 60
  • `filterQuality` parameter has been moved to the `Painter` parameter of the `Image` composable – racs May 09 '23 at 02:31