react-native-image-capinsets icon indicating copy to clipboard operation
react-native-image-capinsets copied to clipboard

discrepancy between debug and release rendering

Open mcconkiee opened this issue 7 years ago • 9 comments

Hi - I have an effect to which I am unclear the issue. When building in debug the module works as expected: dev however in release build, it looks like this: release

the relative code :

render(){
const bubble = StaticIcons.imageForIcon("chat-bubble-light");
const sz = 8;
....
<ImageCapInset
          style={{
            padding: 20
          }}
          source={bubble}
          capInsets={{
            top: sz,
            right: sz,
            bottom: sz,
            left: sz
          }}
        >
          <View>
            <Text>This is a test</Text>
            <Text>This is a test</Text>
            <Text>This is a test</Text>
          </View>
        </ImageCapInset>
....
}

I am unclear how to resolve this issue. Any help is appreciated!

mcconkiee avatar Nov 09 '17 21:11 mcconkiee

I have also noticed this! Any insights since your post, @mcconkiee?

hblumberg avatar Mar 15 '18 16:03 hblumberg

Hi. We're also seeing this. I think it is related to: issue on stackoverflow and the fact that the code in RCTImageCapInsetView.java is storing the density ratio in an int.

int ratio = Math.round(bitmap.getDensity() / 160); int top = mCapInsets.top * ratio;

tcherna avatar Apr 06 '18 03:04 tcherna

@hblumberg can you open a PR with your changes please? https://github.com/Khan/react-native-image-capinsets/commit/063c3d5fd0a5e2edadc8886506dfd755c5a78938

EyMaddis avatar Apr 10 '18 08:04 EyMaddis

I've been trying to read about the difference in bitmap density vs. device density, re @hblumberg's change. It seems to me that ordinarily, they'd match, but if the app didn't provide all the appropriate sized images, then wouldn't the closest bitmap be provided (with the system scaling as required). At that point, wouldn't the bitmap density be a better choice? Thoughts?

tcherna avatar Apr 10 '18 22:04 tcherna

I'd be happy to open a PR with my change, @EyMaddis, but unfortunately it doesn't fix the debug vs. release discrepancy. 1.5x devices (for example) still look distorted on debug builds, but correct on release builds.

I didn't make a PR because of @tcherna's point. I do think it's worth rounding later (after multiplying by the insets), but I'm not sure if folks rely on the existing density calculation.

hblumberg avatar Apr 10 '18 23:04 hblumberg

@hblumberg, Had you tried your code with the later rounding but using the bitmap density calculation to see how it performed with debug/release?

tcherna avatar Apr 10 '18 23:04 tcherna

I did some logging and testing and I actually don't see any difference in the values from getDisplayMetrics().density vs bitmap.getDensity()/160.0f. On the device where I do see a rendering error in debug, the issue is that the bitmap returned is the wrong size compared with release (it looks like its a 2x image vs the scaled image), which doesn't make sense since the factory is always supposed to return an image scaled to the target density (by default).

tcherna avatar Apr 12 '18 23:04 tcherna

We found this an issue too, our solution was to remove the ratio calculation and so the configured nine patch rect area always operates on actual image pixels.

https://github.com/DevopsElectricJukebox/react-native-image-capinsets/commit/e872440f9499bdf28ca1166b0ebc1bc8b721f207

DevopsElectricJukebox avatar Jun 10 '19 16:06 DevopsElectricJukebox

@DevopsElectricJukebox this is working at production env? thanks

mayconmesquita avatar Aug 27 '19 10:08 mayconmesquita