Comments (13)
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 π
from nativescript-drawingpad.
happy to help. your example works like a charm.
from nativescript-drawingpad.
thank you all for helping
from nativescript-drawingpad.
Can your print out the data
and confirm what it is?
from nativescript-drawingpad.
Hi, yep this is crashing my app as well. Also running ns7, my app specifically crashes and closes after this line
image = ImageSource.fromResourceSync(data)
I have also tried:
const pad = this.DrawingPad.nativeElement;
pad.getDrawing()
.then(
(data) => {
console.log(data);
ImageSource.fromData(data)
.then((res) => console.log(res))
.catch((error) => console.log(error));
// let image64 = image.toBase64String('png');
},
(err) => {
console.log(err);
}
)
.catch((e) => console.log(e));
Just crashes
No output or errors though. In my case, the data value is android.graphics.Bitmap@4034c7f
Anything else I can try?
Thanks for the cool plugin
from nativescript-drawingpad.
This def worked at one time π because it was in the demo app and working fine to show the captured image into Image
view in NS after the conversion from bitmap. Not sure what changed.
from nativescript-drawingpad.
Well, the ImageSource does not have a fromResourceSync() method. Could it have to do with how we get it?
from nativescript-drawingpad.
Yea... fromResource...
was for app_Resource images - https://github.com/NativeScript/NativeScript/blob/b8d828bef93154db338939afd9ae4781097fd851/packages/core/image-source/index.android.ts#L96 you can see the source on android grabbing the resources here so in this instance we have the Bitmap already so fromDataSync()
looks to be what you would use.
Try using https://github.com/NativeScript/NativeScript/blob/master/packages/core/image-source/index.android.ts#L152 fromDataSync()
from nativescript-drawingpad.
Ah... I see the issue now.
2021-01-13 09:55:48.547 4802-4802/org.nativescript.demo E/tivescript.dem: JNI ERROR (app bug): attempt to pass an instance of android.graphics.Bitmap as argument 1 to android.graphics.Bitmap android.graphics.BitmapFactory.decodeStream(java.io.InputStream)
2021-01-13 09:55:48.559 4802-4802/org.nativescript.demo A/tivescript.dem: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: bad arguments passed to android.graphics.Bitmap android.graphics.BitmapFactory.decodeStream(java.io.InputStream) (see above for details)
2021-01-13 09:55:48.559 4802-4802/org.nativescript.demo A/tivescript.dem: java_vm_ext.cc:542] from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])
2021-01-13 09:55:48.559 4802-4802/org.nativescript.demo A/tivescript.dem: java_vm_ext.cc:542] "main" prio=5 tid=1 Runnable
That is the crash with fromData
or fromDataSync
we're passing the Bitmap and not a stream into the method so of course that crashes.
from nativescript-drawingpad.
@seankonig it's simply new ImageSource(data)
to create the Image
from a bitmap on android or UIImage on iOS.
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);
});
from nativescript-drawingpad.
Boom, thanks dude.
from nativescript-drawingpad.
getDrawingAsBase64(format?: "png" | "jpg" | "jpeg")
- Promise (returns image as base64 string if successful)
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 :)
from nativescript-drawingpad.
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π
from nativescript-drawingpad.
Related Issues (20)
- Plugin makes my app crash on minimizing (Android) HOT 1
- Dynamically show or embed a word into the Drawingpad? HOT 1
- {N}-Vue error when getDrawing() is called HOT 7
- background of svg image HOT 1
- How to capture event in drawing pad using "nativescript-drawingpad" plugin
- iOS Xcode Build Fails: "linker command failed"...framework not found SignatureView HOT 3
- Windows 10 gradle build failing but working on mac HOT 6
- How to get drawed content without empty space.
- Drawing Pad is cleared if User presses on pad HOT 1
- Feature Request: Events HOT 1
- Add `setDrawing` and `setDrawingSvg` methods HOT 9
- Support for rotating drawing on saving.
- IOS SignatureView not found HOT 1
- IOS : cannot clear transparent background drawing HOT 1
- IOS : Conflicting gestures when drawing pade loaded in a non-fullscreen modal HOT 1
- Keeps saying "module not found" HOT 1
- App closes when getting image HOT 1
- clearDrawing clear also the backgroundImage
- Bug Documentation Angular Section
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-drawingpad.