React Native Pixel Color
Returns the pixel color from a graphic at a given coordinate.
Setup
Install the package:
React-Native 0.29.2+
npm install --save react-native-get-pixel-color
react-native link react-native-get-pixel-color
React-Native < 0.29.2
npm install rnpm -g
rnpm install react-native-get-pixel-color
Android
Note: on latest versions of React Native, you may have an error during the Gradle build on Android (com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim
). Run cd android && ./gradlew clean
to fix this.
Usage example
import PixelColor from 'react-native-get-pixel-color';
PixelColor.getHex(imageUriOrData, { x, y }).then((color) => {
}).catch((err) => {
});
Sample app
Examples are found in the the examples
folder.
API
promise getHex(path, options)
The promise resolves with a string containing the uri of the new file.
Option | Description |
---|
path | Path of image file, or a base64 encoded image string prefixed with 'data:image/imagetype' where imagetype is jpeg or png. |
options | { x: int, y: int } |