Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding borderRadius to Image on Android pixelates the image #29265

Closed
tautvilas opened this issue Jul 2, 2020 · 12 comments
Closed

Adding borderRadius to Image on Android pixelates the image #29265

tautvilas opened this issue Jul 2, 2020 · 12 comments
Labels
Component: Image Needs: Attention Issues where the author has responded to feedback. Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@tautvilas
Copy link

tautvilas commented Jul 2, 2020

Adding borderRadius to Image on Android pixelates the image. I am attaching example images and source code.

Steps To Reproduce

Without border radius

<Image style={} source={require('path/to/image')} />

Screenshot 2020-07-02 at 13 52 31

With border radius

<Image style={{borderRadius: 8}} source={require('path/to/image')} />

Screenshot 2020-07-02 at 13 52 59

This issue prevents me from displaying beautiful HD images for my customers on android. One workaround that I tried was to use container element with borderRadius and overflow: 'hidden', however that introduces jagged borders.

With container border radius and overflow hidden

<View style={{borderRadius: 8, overflow: 'hidden'}}><Image source={require('path/to/image')} /></View>

Screenshot 2020-07-02 at 13 56 18

React Native version:

System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Memory: 246.72 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v12.18.0/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6308749
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Python: 2.7.15 - /usr/local/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.1 => 0.62.1
npmGlobalPackages:
react-native: Not Found

@react-native-bot react-native-bot added Component: Image Platform: Android Android applications. Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. and removed Needs: Triage 🔍 labels Jul 2, 2020
@github-actions
Copy link

github-actions bot commented Jul 2, 2020

⚠️ Missing Environment Information
ℹ️ Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

@react-native-bot react-native-bot removed the Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. label Jul 2, 2020
@fabOnReact
Copy link
Contributor

fabOnReact commented Jul 10, 2020

please provide the full test case including the image. I could not reproduce this bug, I tested in api 28, 29 and on real emulator.

@tautvilas
Copy link
Author

I will try to create example project and will post a link to it

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jul 10, 2020
@tautvilas
Copy link
Author

I have created a project with react-native init where the issue is visible. Here is the link:

https://github.com/tautvilas/ImagePixelationAndroid

I have noticed that adding borderRadius or borderWith to Image styles pixelates the images. Adding code and example screenshot as well.

<Image source={{uri: "https://i.imgur.com/aLVC6XS.png"}} style={{width: 300,height: 300}}/>

<Image source={{uri: "https://i.imgur.com/aLVC6XS.png"}} style={{width: 300,height: 300, borderRadius: 10, borderWidth: 1, borderColor: 'black'}}/>

Screenshot 2020-07-13 at 12 33 17

@fabOnReact
Copy link
Contributor

import React from 'react';
import {
  ScrollView,
  Image,
} from 'react-native';

const App = () => {
  return (
    <ScrollView>
    <Image source={require("./image.png")} style={{ height: 900}} />
    <Image 
      source={require("./image.png")} 
      style={{ height: 900, borderRadius: 10, borderWidth: 1, borderColor: 'black'}} />
    </ScrollView>
  );
};

export default App;

I still can not reproduce this on Android API 28 emulator. I run it with OpelGL graphic accelleration..

Screenshot_1594649505

I can't fix a bug if I can not reproduce it, could depend on your local environment set up (if your emulator is using OpenGL) or depends on the device...

image

Sorry
Thanks for the help

@tautvilas
Copy link
Author

Could you try it on a real device? I have reproduced this on Pixel 3 API 29 emulator (same OpenGL settings as you) and on real device OnePlus 6, Android 10, Oxygen OS 10.3.4

@stale
Copy link

stale bot commented Oct 12, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 12, 2020
@fabOnReact
Copy link
Contributor

You could try fixing this by using prop rendertohardwaretextureandroid with value of true

https://reactnative.dev/docs/view#rendertohardwaretextureandroid
#28881 (comment)

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 4, 2021
@xiangaoole
Copy link

xiangaoole commented May 10, 2022

image

reproduced on my pixel 4a real device.

"react": "17.0.1",
"react-native": "^0.68.2",
"react-native-cli": "^2.0.1"

reproduced in : pixel 4a(Android 12)/Redmi 10x(Android 11)
not reproduced in : HUAWEI P9 Plus(Android 8.0.0)

@xiangaoole
Copy link

You could try fixing this by using prop rendertohardwaretextureandroid with value of true

https://reactnative.dev/docs/view#rendertohardwaretextureandroid #28881 (comment)

Not working for this

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label May 23, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Image Needs: Attention Issues where the author has responded to feedback. Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

4 participants