rn-draw icon indicating copy to clipboard operation
rn-draw copied to clipboard

How can i save the image?

Open julianbonomini opened this issue 6 years ago • 3 comments

I was using updateSVGInfo that I found in another project that includes this one, but it doen't work.

julianbonomini avatar Jan 26 '18 18:01 julianbonomini

Hi @julianbonomini I recently sent this pull request https://github.com/jayeszee/rn-draw/pull/12

gaboelnuevo avatar Jan 27 '18 21:01 gaboelnuevo

Thanks for contributing! @gaboelnuevo . I'll take a look at it soon, sorry for the delay!

jayeszee avatar Mar 01 '18 23:03 jayeszee

I am using expo. If you use expo, then you can use

import { takeSnapshotAsync } from 'expo';

//  ... 
  onPicture = async () => {

    // this.pictureRef is a reference to Component where you draw
    const result = await takeSnapshotAsync(this.pictureRef, {
      result: 'tmpfile',
      // height: pixels,
      // width: pixels,
      quality: 1.0,
      format: 'png',
    });

    // I made this because in my test iOS don't have file:// before URI and I need this
    let uri = (Platform.OS === 'ios') ? ('file://' + result) : result;
    
    // This call my function, you can do anything, this is just for my purpose and example
    this.props.onFinish({
      uri: uri,
      name: (result).split('/').pop(),
      type: 'image/png',
    });
  }

softov avatar Jun 13 '19 03:06 softov