react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

Background transparent not work!

Open juanm4 opened this issue 4 years ago • 8 comments

Background transparent not work.

Version & Platform

 [email protected] 
 [email protected] 

Platform: Android

Expected behavior

If ViewShot has a transparent background, it should get the background color/image on screenshot.

Actual behavior

Always shot an image with white background.

Steps to reproduce the behavior

If you try this code you can see that the background of image is white instead of gray. What is happening?

    <View style={{backgroundColor: 'gray', flex: 1}}>
            <Animated.View
                {...this.panResponder.panHandlers}
                style={[panStyle, styles.circle]}>
                <ViewShot ref="viewShot" options={{ format: 'png', result: 'base64' }} style={{backgroundColor: 'transparent', justifyContent: 'center', alignContent: 'center', alignItems: 'center'}}>
                    <Text>I</Text>
                </ViewShot>
            </Animated.View>
        </View>

The result of base64 images is that:

iVBORw0KGgoAAAANSUhEUgAAAPAAAABMCAYAAABTXTqcAAAABHNCSVQICAgIfAhkiAAAANBJREFUeJzt07ENwlAQBcHDRVEbfVGL64EGnGDZfK00I11y0Ut2BgAAAAAAAAAAAAAAAAAAAAAAANZ6rB7Abd4Hv9fM7P8eAvzuc3DPpYu43LZ6AHCegCFMwBAmYAgTMIQJGMIEDGEChjABQ5iAIUzAECZgCBMwhAkYwgQMYQKGMAFDmIAhTMAQJmAIEzCECRjCBAxhAoYwAUOYgCFMwBAmYAgTMIQJGMIEDGEChjABQ5iAIUzAECZgCBMwhAkYAAAAAAAAAAAAAAAAAAAAbvAFd+EHf8FsvtEAAAAASUVORK5CYII=

As you can see it must has a gray background, but it is white. What Am I doing wrong?

Thanks!

juanm4 avatar Mar 24 '20 18:03 juanm4

I am ok with format: "png", quality: 1, result: "base64".

tarouboy avatar Aug 27 '20 02:08 tarouboy

did you happen to solve it? same issue

dev-apps-code avatar Oct 21 '21 10:10 dev-apps-code

can we get both base64 and png?

AdnanAshraf-gol avatar Nov 22 '22 11:11 AdnanAshraf-gol

Does someone solve the issue?

Pietro-Putelli avatar Jan 13 '23 01:01 Pietro-Putelli

@Pietro-Putelli try giving background in the styles of viewshot wrapper

AdnanAshraf-gol avatar Jan 17 '23 04:01 AdnanAshraf-gol

Here's an example of code, that doesn't work. https://snack.expo.dev/@pietroputelli/react-native-view-shot

Pietro-Putelli avatar Jan 17 '23 10:01 Pietro-Putelli

same here, any update?

RGkevin avatar Oct 12 '23 17:10 RGkevin

The same problem, any update?

michal4511 avatar Feb 27 '24 13:02 michal4511