-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image to base64 on nativescript 7 #61
Comments
Can your print out the |
Hi, yep this is crashing my app as well. Also running ns7, my app specifically crashes and closes after this line
I have also tried:
Just crashes Anything else I can try? |
This def worked at one time 😕 because it was in the demo app and working fine to show the captured image into |
Well, the ImageSource does not have a fromResourceSync() method. Could it have to do with how we get it? |
Yea... Try using https://github.com/NativeScript/NativeScript/blob/master/packages/core/image-source/index.android.ts#L152 |
Ah... I see the issue now.
That is the crash with |
@seankonig it's simply this._myDrawingPad.getDrawing().then(res => {
// convert native image data (bitmap on android) to imageSource for NS
const image = new ImageSource(res);
const base64imageString = image.toBase64String('jpg'); // if you need it as base64
this.set('drawingImage', image);
}); |
Boom, thanks dude. |
I'm adding a method to do this in the source right now, will publish a minor with the new method also 💯 thanks for helping find the bug 👍 |
happy to help. your example works like a charm. |
this will be the method when 4.1.0 is published, just FYI. handles the conversion in the plugin directly since many people seem to need this :) |
That's really cool and makes a lot of sense to add. Thanks for including it. I Will update when you publish the new version👍 |
thank you all for helping |
hi..
i try to convert result to base64, is is my code
getMyDrawing() { const pad = this.DrawingPad.nativeElement; pad.getDrawing().then((data) => { let image = ImageSource.fromResourceSync(data); let image64 = image.toBase64String('png'); }, (err: any) => { console.log(err); }); }
error message
ERROR Error: Uncaught (in promise): Error: JNI Exception occurred (SIGABRT).
thank you
The text was updated successfully, but these errors were encountered: