android - 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
compared with the 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?
解决方案
推荐阅读
- python - Joblib: struct.error: 'I' 格式需要 0 <= number <= 4294967295 保存大型 sklearn 管道对象时
- gitpython - 带有大文件的 gitpython 推送产量(预接收挂钩被拒绝)
- python - 如何让我的 python 脚本与我的 MSP430 启动板通信?
- model-view-controller - 缺少 MVC SSO ADFS 声明
- java - 在 springboot 中使用 auth0 认证的 REST API 的最佳方式
- java - 基于 CAS 的算法 - 线程如何查看最新值?
- angular - 带有多个元素的条带元素 createToken
- r - R/dplyr:根据两个条件替换行值,保持所有其他条件不变
- java - 获取给定字符串的类名
- javascript - 使用 React 和 Gatsby 提交 Pardot 表单处理程序