infoxicator / react-native-star-prnt

React-Native bridge to communicate with Star Micronics Bluetooth/LAN Printers
MIT License
67 stars 65 forks source link

appendBitmap Android with base64 image uri - java.io.FileNotFoundException: No content provider #20

Closed jeremycy closed 5 years ago

jeremycy commented 5 years ago

Hi there.

When using base64 uri image string, IOS works flawlessly but on Android it was throwing java.io.FileNotFoundException: No content provider error.

If I alter bitmap parse with decode/write bytes below it would then work. Just wondering if this feature can be added or if I am missing something and should be handling this differently.

Thanks! Awesome library btw.

uriString = uriString.replace("data:image/png;base64,","");
byte[] decodedString = android.util.Base64.decode(uriString, Base64.DEFAULT);
Bitmap decodedByte = android.graphics.BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);

builder.appendBitmap(decodedByte, diffusion, width, bothScale, rotation);
infoxicator commented 5 years ago

Hi @jeremycy, the appendBitmap command takes a uri not a base64 encoded string. I am surprised it works on iOS. I avoided using base64 string because of performance concerns.

jeremycy commented 5 years ago

@infoxicator I have a strange situation - I am retrieving the base64 string from webview using postMessage to React Native, then try to print it. I suppose I can also do what one user did in another thread, use react native shot then print it that way. Any thoughts?

Still would be nice to add support for base64 string though (although I get why it's weird that it works). Maybe add a appendBase64String ? :)

jeremycy commented 5 years ago

Closing this as not an issue, more like possible feature support.