首页 > 解决方案 > How to remove color banding in react-native Android

问题描述

In the past, I have written a few Android applications natively, and I discovered that the default pixel format often results in banding (at one point, and possibly still, it was RGBA_565, I believe). I have now just begun learning react-native, and I've discovered a similar issue. React Native BackgroundImages seem to suffer from color banding, at least in my scenario.

I have read a bit about the ReactActivityDelegate, but have been unable to find a way to set the pixel format through delegate methods. I have tried getWindow().setFormat(PixelFormat.RGBA_8888) in onAttachedToWindow, but it does not seem to have any effect, at least in a ReactActivity.

I've defined a BackgroundImage as <ImageBackground source={require('./my_img.png')} resizeMode='cover' style={styles.container}>..., but the resulting image has significant color banding as seen below

image

compared with the original image original image For reference, I'm emulating a Pixel 2 XL on Arch Linux, and that is what is reflected in the images.

As Drawable.setDither(boolean) has been deprecated and the property is now ignored, and as far as I know the React Native content view is not drawn on a SurfaceView from which to access a SurfaceHolder and define a PixelFormat, I am not sure how to force RGBA_8888 pixel format or remove the color banding in any other way.

Without explicitly defining the PixelFormat, color banding is expected, but I do not know how to define the PixelFormat for a React Native Android app given its limited access to the native code. Any ideas?

标签: androidreact-native

解决方案


推荐阅读