Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable bitmap filtering in Android Jetpack Compose Image

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.

like image 775
Victor Basso Avatar asked Jun 12 '26 19:06

Victor Basso


1 Answers

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.

like image 175
Victor Basso Avatar answered Jun 14 '26 10:06

Victor Basso