Reputation: 1936
I have a camera plugin in NativeScript 6.0 that returns a ByteArray under Android when taking a picture. How do I load this into an ImageSource? I cannot load it directly or the app will crash.
Upvotes: 0
Views: 133
Reputation: 1936
You can load a ByteArray using the ImageSource.fromData()
method. However, under Android, ImageSource will only accept an input stream:
const input = new java.io.ByteArrayInputStream(myByteArray);
const imageSource = new ImageSource();
imageSource.fromData(input).then(() => {
stuff();
});
Upvotes: 2