keshavkaul / react-native-sketch-view

A React Native component for touch based drawing supporting iOS and Android.
MIT License
99 stars 47 forks source link

Can not load Image from device storage path #26

Open SPATAN18 opened 6 years ago

SPATAN18 commented 6 years ago

I am trying to pass the file path in localSourceImagePath but it is not working. Steps I am following

  1. Click an image using react-native-camera. (it's stored in device storage)
  2. Pass the image path as props to react-native-sketch-view's localSourceImagePath. What am I getting? A zoomed in and rotated version of the image is being displayed.
neerajamnair commented 6 years ago

I made the following changes in /android/src/main/java/com/sketchView/SketchViewContainer.java

Replace openSketchFile function with

public boolean openSketchFile(String localFilePath) {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(localFilePath,bmOptions);
Bitmap bMapScaled = Bitmap.createScaledBitmap(bitmap, 1000, 800, true);
        if(bMapScaled != null) {
            sketchView.setViewImage(bMapScaled);
            return true;
        }
        return false;
    }

1000 and 800 can be replaced with the required width and height