react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

Why is the Skia image not displaying the same as the original image?

Open ralph1233 opened this issue 1 year ago • 4 comments

`import {SafeAreaView, View, Image as RNImage, Text} from 'react-native'; import {Canvas, Image as SkiaImage, useImage} from '@shopify/react-native-skia';

const Test = () => { const skiaImage = useImage(require('../../assets/images/human.jpeg'));

return ( <SafeAreaView style={{ flex: 1, }}> <View style={{ flex: 1, alignItems: 'center', }}> Original Image:

    <RNImage
      style={{
        width: 300,
        height: 300,
      }}
      source={require('../../assets/images/human.jpeg')}
      resizeMode="contain"
    />

    <Text>Skia Image:</Text>

    <Canvas
      style={{
        width: 300,
        height: 300,
      }}>
      <SkiaImage width={300} height={300} image={skiaImage} fit="contain" />
    </Canvas>
  </View>
</SafeAreaView>

); };

export default Test; `

Image

ralph1233 avatar Mar 12 '25 13:03 ralph1233

Try to set sampling prop value to linear instead of nearest by default.

NikitaDudin avatar Mar 12 '25 14:03 NikitaDudin

Try to set sampling prop value to linear instead of nearest by default.

I added this line:

sampling={{ filter: FilterMode.Linear, mipmap: MipmapMode.Linear, }} but it didn't work.

ralph1233 avatar Mar 12 '25 15:03 ralph1233

We added support for sampling options and also p3 colors so now it should really be exactly the same.

wcandillon avatar Jun 17 '25 15:06 wcandillon

the default sampling options are also now more sensible but let me know if you're still experiencing issues and send me the image as well as info on the platforms this potential issue might be occuring

wcandillon avatar Jun 17 '25 15:06 wcandillon